Skip to content

Latest commit

 

History

History
188 lines (118 loc) · 5.53 KB

File metadata and controls

188 lines (118 loc) · 5.53 KB

Disk

List

blkid

Validate

Validate fstab syntax http://serverfault.com/questions/174181/how-do-you-validate-fstab-without-rebooting#509014.

mount --verbose --all --fake

Format by mke2fs

mkfs.ext2 -L fs_boot /dev/sde1

Format by mke2fs to fat32

Format usb to fat32 (a-la mkdosfs)

mkfs.vfat -F 32 /dev/sdg1

Set number of inodes by mke2fs

mkfs.ext4 -N 1000432 /dev/sda5

http://stackoverflow.com/questions/3618820/how-many-bytes-per-inodes.

tune2fs -l /dev/sda5 | grep Inode

Free/used space

df -hi

Directories list sizes

du -sh ./*/

Finding largest files/directories

ls -l /dev/disk/by-uuid | grep sda1

dd copy partition

dd free free space

resize2fs /dev/sda99

dd create ISO

Copy from cd-rom disc to ISO image

dd if=/dev/cdrom of=myimage.iso

dd create usb

Copy ISO image to bootable usb

dd if=path/to/your.iso of=/dev/your-usb

dd benchmark

https://haydenjames.io/web-host-doesnt-want-read-benchmark-vps

dd if=/dev/zero of=/tmp/foobar bs=1M count=1024 conv=fdatasync

dd other

dd if=/dev/sdb of=mybackup.img bs=130M count=1
dd if=bootldr.rom of=/dev/sdb
dd if=debian-eeepc.img of=/dev/sdf

Free space/space usage

Find duplicate files

Mount cdrom

blkid
mount /dev/sr0 path/to/mnt

Mount raw disk image (ext3, ext4 and so on)

https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device#69447

Get the sector size and the sector start of the partition:

# fdisk -lu path/to/image.raw
Disk path/to/image.raw: 90 GiB, 96636764160 bytes, 188743680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000b7568
Device             Boot Start       End   Sectors Size Id Type
path/to/image.raw1       2048     63487     61440  30M 82 Linux swap / Solaris
path/to/image.raw2 *    63488 188743678 188680191  90G 83 Linux

Calculate the offset from the start of the image to the partition start multiplying sector size to sector start: 512 * 63488 = 32505856

Mount partition on loop devices:

losetup -o 32505856 /dev/loop0 path/to/image.raw

Mount partition on file system:

mount /dev/loop0 /mnt/image_raw

fdupes find duplicate files

https://github.com/adrianlopezroche/fdupes, https://unix.stackexchange.com/questions/71176/find-duplicate-files#71178

fdupes --recurse .

fslint find duplicate files

https://unix.stackexchange.com/questions/71176/find-duplicate-files#71201

/usr/share/fslint/fslint/findup ./

Check disk

Check/clean disk after reboot

touch /forcefsck

USB Win

https://askubuntu.com/questions/1281698/what-is-the-best-way-to-format-a-usb-stick-such-that-it-can-be-used-with-both-li#1281771

fdisk /dev/sda
n
t 7
mkfs.exfat /dev/sda1

Other

bchunk Dungeon_Keeper.BIN Dungeon_Keeper.cue Dungeon_Keeper.iso
modprobe loop && mount -t iso9660 -o loop tmp/fdfullcd.iso mnt/iso
mount -t vfat /dev/sdc1 mnt/usbdisk/ \
      -o uid=danil,gid=danil,nosuid,shortname=mixed,umask=077
mount -t ext2 ~/restore.img /mnt/img -o ro,loop,offset=32256
mount -t cifs "//192.168.91.3/store (e)" mnt/black_server/ \
      -o "workgroup=darout,username=danil,iocharset=utf8,codepage=cp1251"
mount --rbind olddir newdir
fsck /dev/sdg1