Some things I consistently have to look up how to do. This is mainly a reference for myself to remember how to do certain things in Linux.
Here is an example command to transfer files remote host to local by only including directories in the host
's /path/to/files
directory that have the directory_prefix
(and include all their contents) and exclude everything else:
rsync -avW host:/path/to/files/ ./my/local/dir --include 'directory_prefix*/***' --exclude '*'
- This post gives helpful advice on how to handle
--include
/--exclude
withrsync
.
rsync -e 'ssh -p 5522' -av user@remote:/path/to/transfer ./local/path/to/save/to
- Execute
lsblk
to see what your drive partitions are. Example output:
sda 8:0 0 931.5G 0 disk
└─sda1 8:1 0 931.5G 0 part /media/data_haro
sdb 8:16 0 3.7T 0 disk
├─sdb1 8:17 0 200M 0 part
└─sdb2 8:18 0 3.7T 0 part /media/adam/LL4MA-D2
nvme0n1 259:0 0 465.8G 0 disk
└─nvme0n1p1 259:1 0 465.8G 0 part /
- Create new directory to mount drive to
sudo mkdir /media/data_haro
- Mount the drive
sudo mount /dev/sda1 /media/data_haro
- Install GParted
sudo apt install gparted
- Open GParted and select the drive you want to auto-mount. See what it's filesystem type is.
- Edit
/etc/fstab
with root permissions
sudo emacs /etc/fstab
- Add a line at the bottom of the file that looks like
/dev/sda1 /media/data_haro ext4 defaults 0 2
-
First column is drive partition to mount.
-
Second column is mount point.
-
Third column is filesystem type (from GParted).
-
Fourth column is options, leave as
defaults
. -
Fifth column leave as
0
. -
Sixth column is
fsck
which determines filesystem order. Only options are0 (no check)
,1 (check first)
, and2 (check second)
. Only boot should be1
, additional drives should be2
. -
Ubuntu: Mount The Drive From Command Line - Simple instructions for mounting a hard drive manually and setting up
fstab
to auto-mount on startup.
You may need to change the permissions on the drive:
sudo chown -R username:username /media/data_haro
where you should set username
to be your username.
Note if you do the auto-mounting and then decide to remove the drive, you must comment out the entry in /etc/fstab
. Otherwise you may find yourself unable to boot the OS and enter emergency mode like described here.