# lshw -C disk # lsblk
# fdisk -l # fdisk -l /dev/sda # lsblk -o name,label,uuid # man sfdisk
# mount /dev/cdrom /mnt
Можно не только монтировать, но и запрограммировать определенные действия, например бэкап.
# parted -a optimal /dev/sdb (parted) mklabel gpt (parted) unit mib (parted) mkpart primary 1 -1 (parted) print (parted) quit
# fdisk /dev/sdb n p 1 <enter> <enter> w
# fdisk -l /dev/sdb
# mkfs -t ext4 /dev/sdb1 # file -s /dev/sdb1
# mkdir /disk2 # mount /dev/sdb1 /disk2 # fuser -cu /disk2 # umount /disk2
# blkid # cat /etc/fstab
... # UUID=4ba44a69-3bf8-4e3a-8b65-589fae005f80 /disk2 ext4 defaults 0 0 # /dev/sdb1 /disk2 ext4 defaults 0 0
# apt install cryptsetup # cryptsetup -y luksFormat /dev/sdb1 # cryptsetup luksDump /dev/sdb1
# cryptsetup luksOpen /dev/sdb1 disk2 # mkfs -t ext4 /dev/mapper/disk2 # mount /dev/mapper/disk2 /disk2
# umount /disk2 # cryptsetup luksClose disk2
# losetup /dev/loop0 /disk2/filedisk # losetup -a # mkfs.ext3 /dev/loop0 # mount -t ext3 /dev/loop0 /mnt # umount /mnt/ # losetup -d /dev/loop0 # cat /etc/fstab
... /disk2/filedisk /filesystem ext3 loop 0 0
debian# apt install lvm2
# vgs
... ubuntu-vg ...
# lvs ubuntu-vg LV VG ... ubuntu-lv ubuntu-vg ...
Превращаем его в физический том LVM
# pvcreate /dev/sdb
Добавляем физический том к группе томов
# vgextend ubuntu-vg /dev/sdb # pvs
# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
# df -h / # resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv или # xfs_growfs / # df -h /
root@gate:~# apt install lvm2
root@gate:~# pvcreate /dev/sdb root@gate:~# pvs root@gate:~# pvdisplay
root@gate:~# vgcreate vg1 /dev/sdb root@gate:~# pvs root@gate:~# pvdisplay root@gate:~# vgdisplay vg1
root@gate:~# lvcreate -n lv1 -L 1000M vg1 root@gate:~# lvdisplay root@gate:~# lvdisplay /dev/vg1/lv1
root@gate:~# mkfs.ext4 /dev/vg1/lv1 или root@gate:~# mkfs.ext4 /dev/mapper/vg1-lv1 root@gate:~# mount /dev/vg1/lv1 /disk2 или root@gate:~# mount /dev/mapper/vg1-lv1 /disk2 root@gate:~# blkid /dev/mapper/vg1-lv1
root@gate:~# pvcreate /dev/sdc root@gate:~# vgextend vg1 /dev/sdc root@gate:~# pvs root@gate:~# pvdisplay root@gate:~# vgdisplay vg1
root@gate:~# lvextend -l +100%FREE /dev/vg1/lv1
root@gate:~# resize2fs /dev/vg1/lv1 root@gate:~# xfs_growfs / root@gate:~# df -h
root@gate:~# umount /disk2
root@gate:~# e2fsck -f /dev/vg1/lv1 root@gate:~# resize2fs /dev/vg1/lv1 990M
root@gate:~# lvreduce /dev/vg1/lv1 -L 1000M Rounding up size to full physical extent 1000.00 MiB WARNING: Reducing active logical volume to 1000.00 MiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv1? [y/n]: y Reducing logical volume lv1 to 1000.00 MiB Logical volume lv1 successfully resized
root@gate:~# mount /dev/vg1/lv1 /disk2
root@gate:~# pvmove /dev/sdb
root@gate:~# vgreduce vg1 /dev/sdb Removed "/dev/sdb" from volume group "vg1" root@gate:~# pvremove sdb root@gate:~# pvs
# lvcreate --size 1G --snapshot --name www_snap /dev/vg1/www # lvs Что-то ломаем в контейнере # systemctl stop lxc@www # lvconvert --merge /dev/vg1/www_snap
# apt install quota # cat /etc/fstab
... #/dev/sda1 / ext4 errors=remount-ro 0 1 /dev/sda1 / ext4 errors=remount-ro,usrquota 0 1
# mount -o remount / # quotacheck -cum / # quotaon / # edquota user1
# For 10Mb ... soft hard ... ... 10000 10240 ...
# edquota -p user1 user2