Linux Mount Drive: Difference between revisions
Jump to navigation
Jump to search
(20 intermediate revisions by the same user not shown) | |||
Line 104: | Line 104: | ||
<source lang="bash"> | <source lang="bash"> | ||
mkfs.ext4 /dev/sdb1 | mkfs.ext4 /dev/sdb1 | ||
mkdir -p /nas/ | mkdir -p /nas/nas_00 | ||
chmod 775 /nas/ | chmod 775 /nas/nas_00 | ||
mount /dev/sdb1 /nas/ | mount /dev/sdb1 /nas/nas_00 | ||
</source> | </source> | ||
Line 117: | Line 117: | ||
└─sda2 8:2 0 465.5G 0 part / | └─sda2 8:2 0 465.5G 0 part / | ||
sdb 8:16 0 3.7T 0 disk | sdb 8:16 0 3.7T 0 disk | ||
└─sdb1 8:17 0 3.7T 0 part /nas/ | └─sdb1 8:17 0 3.7T 0 part /nas/nas_00 | ||
" | " | ||
</source> | </source> | ||
==Auto Mount== | |||
<source lang="bash"> | <source lang="bash"> | ||
blkid | blkid | ||
Line 129: | Line 130: | ||
' | ' | ||
</source> | </source> | ||
'''fstab entry might be like below:''' | |||
PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 auto,nofail,x-systemd.device-timeout=30 0 0 | |||
PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 nofail,x-systemd.device-timeout=30 0 0 | |||
PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 auto,nofail,noatime,rw,user 0 0 | |||
PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 defaults,nofail,user_xattr,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0,acl 0 2 | |||
<source lang="bash"> | <source lang="bash"> | ||
Line 136: | Line 143: | ||
PARTUUID=d8d2ce21-01 /boot vfat defaults 0 2 | PARTUUID=d8d2ce21-01 /boot vfat defaults 0 2 | ||
PARTUUID=d8d2ce21-02 / ext4 defaults,noatime 0 1 | PARTUUID=d8d2ce21-02 / ext4 defaults,noatime 0 1 | ||
PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 auto,nofail,noatime,rw,user 0 0 | |||
# a swapfile is not a swap partition, no line here | # a swapfile is not a swap partition, no line here | ||
# use dphys-swapfile swap[on|off] for that | # use dphys-swapfile swap[on|off] for that | ||
" | |||
</source> | |||
<source lang="bash"> | |||
mount -a | |||
findmnt --verify | |||
findmnt --verify --verbose | |||
findmnt --verify --tab-file /etc/fstab --verbose | |||
</source> | |||
<source lang="bash"> | |||
lsblk | |||
:" | |||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |||
sda 8:0 0 465.8G 0 disk | |||
├─sda1 8:1 0 256M 0 part /boot | |||
└─sda2 8:2 0 465.5G 0 part / | |||
sdb 8:16 0 3.7T 0 disk | |||
└─sdb1 8:17 0 3.7T 0 part /nas/nas_00 | |||
" | " | ||
</source> | </source> | ||
Line 178: | Line 205: | ||
|} | |} | ||
==Resize Volume Group== | |||
1. '''unmount:''' | |||
sudo umount /dev/mmcblk0p3 | |||
2. '''resize:''' physical volume | |||
sudo pvresize /dev/mmcblk0p3 | |||
3. '''validate:''' physical volume size | |||
sudo pvs | |||
4. '''resize:''' logical volume | |||
sudo lvresize -L +20480 fedora_fedora/root /dev/mmcblk0p3 | |||
sudo lvresize -L +20G fedora_fedora/root /dev/mmcblk0p3 | |||
sudo lvresize -l +100%FREE /dev/fedora_fedora/root | |||
df -h / | |||
sudo xfs_growfs /dev/fedora_fedora/root | |||
sudo resize2fs /dev/fedora_fedora/root | |||
5. '''validate:''' logical volume size | |||
sudo lvs | |||
df -h / | |||
6. '''remount:''' | |||
sudo mount -a | |||
==Knowledge== | ==Knowledge== | ||
Line 185: | Line 238: | ||
apt update | apt update | ||
apt install lshw | apt install lshw | ||
apt install fuse3 | |||
apt install eject | apt install eject | ||
apt install gdisk | apt install gdisk | ||
Line 192: | Line 246: | ||
apt install udisks2 | apt install udisks2 | ||
apt install progress | apt install progress | ||
apt install nfs-common | |||
cat /proc/mounts | cat /proc/mounts | ||
mount|grep ^/dev | mount|grep ^/dev | ||
ls -la /mnt/ | ls -la /mnt/ | ||
mount -a | mount -a | ||
mv /opt/finology/ /nas/nas_00/ | |||
ln -s /nas/nas_00/finology /opt/finology | |||
chown -h pi:pi /opt/finology | |||
| valign="top" | | | valign="top" | | ||
Line 207: | Line 266: | ||
ls -la /dev/sda* | ls -la /dev/sda* | ||
eject /dev/dvd | eject /dev/dvd | ||
parted -l | |||
fdisk -l | fdisk -l | ||
mount -l | mount -l | ||
df -aTh | df -aTh | ||
df -hT | |||
mount | mount | ||
lshw | lshw | ||
sudo parted -l|grep ntfs | |||
sudo mkdir /mnt/e-drive | |||
sudo mount -t ntfs-3g /dev/nvme0n1p5 /mnt/e-drive | |||
|} | |} | ||
Line 255: | Line 320: | ||
| valign="top" | | | valign="top" | | ||
* [https://raspberrypi.stackexchange.com/questions/106090/ Does Raspberrypi 4 support boot from GPT partitioned Disk] | * [https://raspberrypi.stackexchange.com/questions/106090/ Does Raspberrypi 4 support boot from GPT partitioned Disk] | ||
* [https://unix.stackexchange.com/questions/347013/ <code>fstab</code> meaning of <code>noauto,nofail,user,noatime</code>] | |||
* [https://developer.ibm.com/technologies/linux/tutorials/l-gpt/ Make the most of large drives with GPT and Linux] | * [https://developer.ibm.com/technologies/linux/tutorials/l-gpt/ Make the most of large drives with GPT and Linux] | ||
* [https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh Mount Remote File Systems Over SSH] | * [https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh Mount Remote File Systems Over SSH] | ||
Line 263: | Line 329: | ||
* [https://github.com/billw2/rpi-clone RPI Clone] | * [https://github.com/billw2/rpi-clone RPI Clone] | ||
* [https://wiki.archlinux.org/index.php/GPT_fdisk GPT fdisk] | * [https://wiki.archlinux.org/index.php/GPT_fdisk GPT fdisk] | ||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
* [https://forum.openmediavault.org/index.php?thread/20727-can-t-create-shared-folders/ Can't Create Shared Folders] | |||
* [https://linuxroutes.com/extend-linux-mount-point/ Extend Linux Mount Point] | |||
| valign="top" | | |||
| valign="top" | | |||
|} | |} |
Latest revision as of 23:24, 20 January 2023
mount df lsblk findmnt ─────────────────────────────────────────────── findmnt / TARGET SOURCE FSTYPE OPTIONS / /dev/mmcblk0p2 ext4 rw,noatime |
lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 3.7T 0 disk ├─sda1 8:1 0 128M 0 part └─sda2 8:2 0 3.7T 0 part mmcblk0 179:0 0 59.6G 0 disk ├─mmcblk0p1 179:1 0 256M 0 part /boot └─mmcblk0p2 179:2 0 59.4G 0 part / |
Formate
gdisk /dev/sdb
:"
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
"
gdisk /dev/sdb
:"
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): v
No problems found. 7814037101 free sectors (3.6 TiB) available in 1
segments, the largest of which is 7814037101 (3.6 TiB) in size.
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-7814037134, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-7814037134, default = 7814037134) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'
Command (? for help): v
No problems found. 2014 free sectors (1007.0 KiB) available in 1
segments, the largest of which is 2014 (1007.0 KiB) in size.
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
"
mkfs.ext4 /dev/sdb1
mkdir -p /nas/nas_00
chmod 775 /nas/nas_00
mount /dev/sdb1 /nas/nas_00
lsblk
:"
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 256M 0 part /boot
└─sda2 8:2 0 465.5G 0 part /
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part /nas/nas_00
"
Auto Mount
blkid
:'
/dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="6284-658D" TYPE="vfat" PARTUUID="d8d2ce21-01"
/dev/sda2: LABEL="rootfs" UUID="3a324232-335f-4617-84c3-d4889840dc93" TYPE="ext4" PARTUUID="d8d2ce21-02"
/dev/sdb1: UUID="d585a513-6325-450d-95d8-7c7f1d56f08e" TYPE="ext4" PARTLABEL="nas0" PARTUUID="387a56e5-25a9-4953-8d50-00c2d6ad6539"
'
fstab entry might be like below: PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 auto,nofail,x-systemd.device-timeout=30 0 0 PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 nofail,x-systemd.device-timeout=30 0 0 PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 auto,nofail,noatime,rw,user 0 0 PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 defaults,nofail,user_xattr,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0,acl 0 2
cat /etc/fstab
:"
proc /proc proc defaults 0 0
PARTUUID=d8d2ce21-01 /boot vfat defaults 0 2
PARTUUID=d8d2ce21-02 / ext4 defaults,noatime 0 1
PARTUUID=387a56e5-25a9-4953-8d50-00c2d6ad6539 /nas/nas_00 ext4 auto,nofail,noatime,rw,user 0 0
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
"
mount -a
findmnt --verify
findmnt --verify --verbose
findmnt --verify --tab-file /etc/fstab --verbose
lsblk
:"
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 256M 0 part /boot
└─sda2 8:2 0 465.5G 0 part /
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part /nas/nas_00
"
Mounting
mount ─────────────────────────────────────────────── lsblk mkdir /mnt/chorke mount /dev/sda2 /mnt/chorke/ ls -lah /mnt/chorke/ |
unmount ─────────────────────────────────────────────── lsblk umount /mnt/chorke/ ls -lah /mnt/chorke/ rm -rf /mnt/chorke/ |
Unmounting
udisks2 (new system) ─────────────────────────────────────────────── lsblk udisksctl unmount -b /dev/sda1 udisksctl power-off -b /dev/sda |
udisks (old system) ─────────────────────────────────────────────── lsblk udisks --unmount /dev/sda1 udisks --detach /dev/sda |
Resize Volume Group
1. unmount: sudo umount /dev/mmcblk0p3 2. resize: physical volume sudo pvresize /dev/mmcblk0p3 3. validate: physical volume size sudo pvs 4. resize: logical volume sudo lvresize -L +20480 fedora_fedora/root /dev/mmcblk0p3 sudo lvresize -L +20G fedora_fedora/root /dev/mmcblk0p3 sudo lvresize -l +100%FREE /dev/fedora_fedora/root df -h / sudo xfs_growfs /dev/fedora_fedora/root sudo resize2fs /dev/fedora_fedora/root 5. validate: logical volume size sudo lvs df -h / 6. remount: sudo mount -a
Knowledge
─────────────────────────────────────────────── apt update apt install lshw apt install fuse3 apt install eject apt install gdisk apt install rsync apt install hdparm apt install ntfs-3g apt install udisks2 apt install progress apt install nfs-common cat /proc/mounts mount|grep ^/dev ls -la /mnt/ mount -a mv /opt/finology/ /nas/nas_00/ ln -s /nas/nas_00/finology /opt/finology chown -h pi:pi /opt/finology |
─────────────────────────────────────────────── rsync -r --progress source target udisksctl unmount -b /dev/sda1 lsblk -o NAME,FSTYPE,UUID cat /proc/self/mounts hdparm -N /dev/sda watch progress -w ls -la /dev/sda* eject /dev/dvd parted -l fdisk -l mount -l df -aTh df -hT mount lshw sudo parted -l|grep ntfs sudo mkdir /mnt/e-drive sudo mount -t ntfs-3g /dev/nvme0n1p5 /mnt/e-drive |
SD Clone
apt search piclone apt install piclone ./sdclone /dev/sda /dev/mmcblk0 ./sdclone /dev/sda /dev/macblk0
RPI Clone
If sda size more than 2TB git clone https://github.com/billw2/rpi-clone.git; cd rpi-clone cp rpi-clone rpi-clone-setup /usr/local/sbin rpi-clone-setup -t testhostname rpi-clone -f -p 256M sda