วันจันทร์ที่ 11 กันยายน พ.ศ. 2566

Mount drive in linux and set auto-mount at boot

 https://confluence.jaytaala.com/display/TKB/Mount+drive+in+linux+and+set+auto-mount+at+boot


Guide to mount a drive in linux (deb/ubuntu) and set to auto-mount at boot.

Mount drive

Make a folder (will be mount point)

sudo mkdir /media/data
sudo mount /dev/sdb1 /media/data

Now you can access the drive at /media/data.

Auto-mount at boot

We want the drive to auto-mount at boot.  This usually means editing /etc/fstab.

Firstly, it's always best to use the drives UUID.  To find the drive's UUID do

ls -al /dev/disk/by-uuid/

Copy the resultant UUID (for your disk) and then open fstab for editing (note I'm using vim here but use whatever editor you prefer):

sudo vim /etc/fstab

You want to add an entry for the UUID and mount point.  Below is an example of an fstab file with an entry added for the mount above:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdb1 during installation
UUID=63a46dce-b895-4c1f-9034-b1104694a956 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sdb5 during installation
UUID=b9b9ee49-c69c-475b-894b-1279d44034ae none            swap    sw              0       0
# data drive
UUID=19fa40a3-fd17-412f-9063-a29ca0e75f93 /media/data   ext4    defaults        0       0

Note: the entry added is the last line.

Test fstab

We always want to test the fstab before rebooting (an incorrect fstab can render a disk unbootable).  To test do:

findmnt --verify

check the last line for errors.  Warnings can help in improving your fstab.

Unmounting drive with umount

You can unmount drives using umount.  For example, to unmount the data drive above mount at /media/data you would do:

sudo umount /media/data

วันพฤหัสบดีที่ 10 สิงหาคม พ.ศ. 2566

วันอาทิตย์ที่ 6 สิงหาคม พ.ศ. 2566

Checking the Health of a Storage Device in Linux

 https://www.baeldung.com/linux/storage-device-check-health

dnf install  e2fsprogs


 badblocks -sv /dev/sdd1


Checking blocks 0 to 15247359
Checking for bad blocks (read-only test):   0.00% done, 0:00 elapsed. (0/0/0 err  0.53% done, 0:04 ela    0.81% done, 0:  1.08% done, 0:08 elapse  1.22% done, 0:09 done                                                 
Pass completed, 0 bad blocks found. (0/0/0 errors)


mount: unknown filesystem type ‘LVM2_member’.

 https://serverok.in/mount-unknown-filesystem-type-lvm2_member


https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Mount-mount-dev-mapper-vg00-lvol1-on-mnt-StorageMedia-failed-Structure-needs-cleaning-error-when-trying-to-mount-storage-in-Flame.html


https://www.linuxsysadmins.com/resize-root-lvm-partition-in-linux/


https://www.linuxsysadmins.com/resize-root-lvm-partition-in-linux/


https://linuxhint.com/xfs-repair/#post-276244-_sx44t3s3ishr


************************* Linux Emergency Mode Error RHEL/CentOS

https://www.youtube.com/watch?v=mnZ3YUnKzDU

https://systemzone.net/lvm-management-in-centos-red-hat-7-linux/



 




Activating Volume Group


# vgchange -ay


Check for file System error


# e2fsck -ff /dev/mapper/rhel-root


xfs_repair -L  /dev/mapper/centos-root