I’m been think about how to backup Samba to a USB thumb drive since I posted Backup/Recovery for Samba and I found a way.
Place the thumb drive in minimal CentOS and does this step. ‘-io’ allows for a listing of all the labels you put in lsblk. Note: If you already made a ext4 partition on the thumb drive skip the first three steps and go to the step 4.
lsblk -io kname,type,size,model
Find the drive for USB and does this step. My thumb drive is sdb. I think it makes it Linux partition on the thumb drive but I can’t find out for sure.
echo '0,' | sfdisk /dev/sdb
Next step is make a ext4 partition on the whole thumb drive and I made mine ‘backups’ for it’s name.
mke2fs -T ext4 /dev/sdb1 -L backups
Then make a mount point for the USB thumb drive.
mkdir -p /mnt/usb
The last step is too add line at the end in your /etc/fstab file.
/dev/sdb1 /mnt/usb ext4 defaults 0 0
or another Step 4 and Step 5:
If you want to make sure that the only USB thumb drive is mounted, do this step first:
lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 xfs ed4f40b7-c65c-431a-ad2e-e5efb7b92410 /boot └─sda2 LVM2_mem M3uGgj-ff3Y-dguK-BpUI-26kx-L5M8-8ecccy ├─cl-root xfs c4d4ad4c-cfe9-4288-bb22-fcb45eaa4a4c / └─cl-swap swap 9d68498d-0708-4a2e-a752-7c2346d6ab0c [SWAP] sdb └─sdb1 ext4 backups 93bafca2-1522-4fe1-9837-f8685e390309 /mnt/usb sr0 iso9660 CentOS 7 x86_64 2016-12-05-13-55-45-00
Then using the UUID characters, highlighted in bold for the thumb drive, add this line instead to to the /etc/fstab.
UUID=93bafca2-1522-4fe1-9837-f8685e390309 /mnt/usb ext4 defaults 0 0
Then restart CentOS and your thumb drive should be auto-mounted as /mnt/usb.
If you want to remove the thumb drive while CentOS is on, do this step: