04 May 2024 - Posted in
Server Configuration by
jangseo
1. Get information about block device
lsblk --fs
2. partion the new disk
cfdisk /dev/sda
> New -> Primary -> Specify size in MB
> Write
> Quit
3. Format the new disk with XFS filesystem
mkfs.xfs /dev/sda
mkfs.xfs: command not found
apt-get install xfsprogs
mkfs.xfs: Format the filesystem
xfs_admin: Change the parameters of the filesystem
xfs_growfs: Decrease the size of the filesystem
xfs_repair: Check and repair the filesystem
xfs_freeze: Suspend access to an XFS filesystem; this makes consistent backups easier
xfs_copy: Fast copy the contents of an XFS filesystem
In case repair, always unmount first, repair, mount.
umount /mnt/5ton
xfs_repair /mnt/5ton
4. run fdisk -l to see if the system can use it.
Disk /dev/sda: 21.4 GB, 21474836480 bytes
......
Disk /dev/sdb: 50000 GB, 5000002254720 bytes
Disk /dev/sdb doesn't contain a valid partition table
....if error, attempt to repair bad superblocks on the drive
fsck /dev/sda
When it asks to repair blocks select yes by pressing 'y'
5. Check whole block device: sudo lsbl
6. Get UUID run sudo blkid /dev/sda
7. sudo nano /etc/fstab
add followings;
UUID=d90e3189-12cd-4d16-8fe9-cf362b5f267d /disk2 xfs defaults 1
if doesn't start after reboot;
(UUID=c853a0fe-93fc-4df1-9b08-1429055b451b /disk2 auto nofail,rw,user,errors=remount-ro 0 0)
Save and close the file.
8. sudo mkdir /home/disk2
sudo mount -t xfs /dev/sda /home/disk2
sudo umount /dev/sda (change /etc/fstab )
9. cat /etc/fstab
Verification
sudo df
systemctl daemon-reload
reboot
================================================
Summing up
Step 1 – Get information about block device
lsblk
lsblk --fs
Step 2 – Print UUID for Linux block device
sudo blkid /dev/sda
Step 3 – Edit /etc/fstab to mount partitions using UUID
sudo nano /etc/fstab
And update it as follows to mount the /dev/sdb at /disk2/ directory using UUID:
UUID=d90e3189-12cd-4d16-8fe9-cf362b5f267d /disk2 xfs defaults 1
sudo mount -a
Step 4 – Verification
run sudo df
That's it.