Linux Mount Drive: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
Line 109: Line 109:


<source lang="bash">
<source lang="bash">
df -h
lsblk
:"
:"
Filesystem      Size  Used Avail Use% Mounted on
Filesystem      Size  Used Avail Use% Mounted on
/dev/root      458G  3.7G 431G   1% /
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
/dev/sda1      253M   56M  197M 22% /boot
sda      8:0    0 465.8G 0 disk
/dev/sdb1      3.6T   89M  3.4T  1% /nas/disk0
├─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/disk0
"
"
</source>
</source>

Revision as of 06:50, 6 December 2020

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/disk0
mount /dev/sdb1 /nas/disk0
lsblk
:"
Filesystem      Size  Used Avail Use% Mounted on
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/disk0
"

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

Knowledge

───────────────────────────────────────────────
apt update
apt install lshw
apt install eject
apt install gdisk
apt install rsync
apt install hdparm
apt install ntfs-3g
apt install udisks2
apt install progress
cat /proc/mounts
mount|grep ^/dev
ls -la /mnt/
mount -a
───────────────────────────────────────────────
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
fdisk -l
mount -l
df -aTh
mount
lshw

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

References