Commands tagged partition (26)

  • Yields entries in the form of "/dev/hda1" etc. Use this if you are on a new system and don't know how the storage hardware (ide, sata, scsi, usb - with ever changing descriptors) is connected and which partitions are available. Far better than using "fdisk -l" on guessed device descriptors. Show Sample Output


    13
    hwinfo --block --short
    Schneckentreiber · 2009-04-24 11:13:31 10
  • Shows the UUID of the given partition (here /dev/sda7). Doesn't need to be root. Show Sample Output


    9
    blkid /dev/sda7
    lineak · 2010-09-05 12:20:45 6
  • Suppose you made a backup of your hard disk with dd: dd if=/dev/sda of=/mnt/disk/backup.img This command enables you to mount a partition from inside this image, so you can access your files directly. Substitute PARTITION=1 with the number of the partition you want to mount (returned from sfdisk -d yourfile.img). Show Sample Output


    8
    INFILE=/path/to/your/backup.img; MOUNTPT=/mnt/foo; PARTITION=1; mount "$INFILE" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]
    Alanceil · 2009-03-06 21:29:13 11

  • 8
    lsblk -o name,size
    justsomeguy · 2022-03-04 04:29:47 374
  • See size of partitions as human readable and get extra informations about hdd and partitions Show Sample Output


    5
    parted /dev/sda print
    mesuutt · 2012-06-05 09:11:06 3
  • Instead of calculating the offset and providing an offset option to mount, let lomount do the job for you by just providing the partition number you would like to loop mount.


    4
    lomount -diskimage /path/to/your/backup.img -partition 1 /mnt/foo
    olorin · 2009-07-22 11:32:52 16

  • 4
    losetup /dev/loop0 harddrive.img; kpartx -a -v /dev/loop0; mount /dev/mapper/loop0p1 /mountpoint/
    oernii3 · 2010-10-30 11:52:11 7
  • Shows all block devices in a tree with descruptions of what they are.


    4
    lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,MODEL,MOUNTPOINT
    BasketCase · 2012-09-12 15:30:25 4
  • It is the same but more faster real 0m0,007s user 0m0,011s sys 0m0,000s with my solution real 0m0,038s user 0m0,044s sys 0m0,000s with your solution :) Show Sample Output


    3
    lsblk | grep -v part | awk '{print $1 "\t" $4}'
    gecco · 2022-01-11 13:31:04 232

  • 2
    sfdisk -d /dev/sda | sed 's/sda/sdb/g' | sfdisk /dev/sdb
    kobayashison · 2009-12-22 23:35:30 4
  • Reports all local partitions having more than 90% usage. Just add it in a crontab and you'll get a mail when a disk is full. (sending mail to the root user must work for that) Show Sample Output


    2
    df -l | grep -e "9.%" -e "100%"
    dooblem · 2010-04-26 17:57:54 3
  • The above command assumes the lost data is on /dev/sda and you previously issued the following command to mount _another_ disk or partition (/dev/sdb1) on /recovery sudo mount /dev/sdb1 /recovery If you don't do this, the data could be overwrited! foremost is a very powerful carving tool. By default foremost recovers all known file types. If you want to reduce the amount of files that are recovered you can specify the file type you are looking for. Read the man page to know the available file types. i.e to recover JPEG pictures append to foremost the switch -tjpg


    2
    sudo foremost -i /dev/sda -o /recovery
    vlan7 · 2010-08-19 22:27:41 6
  • Necessary for fsck for example. The remount functionality follows the standard way how the mount command works with options from fstab. It means the mount command doesn't read fstab (or mtab) only when a device and dir are fully specified. After this call all old mount options are replaced and arbitrary stuff from fstab is ignored, except the loop= option which is internally generated and maintained by the mount command. It does not change device or mount point.


    2
    mount -o remount,ro /dev/foo /
    vlan7 · 2010-10-30 03:51:53 6
  • `blkid` is an interface to libuuid - it can read Device Mapper, EVMS, LVM, MD, and regular block devices. -c /dev/null - Do not use cached output from /etc/blkid.tab or /etc/blkid/blkid.tab (RHEL) -i - Display I/O Limits (aka I/O topology) information (not available in RHEL) -p - Low-level superblock probing mode (not available in RHEL) Show Sample Output


    2
    blkid -c /dev/null
    mhs · 2012-09-12 13:34:41 7
  • lsblk | grep mountpoint Show Sample Output


    2
    lsblk | grep <mountpoint>
    totti · 2014-02-05 09:41:00 8
  • Use lsbk (list block) and jq (to manipulate a JSON on the command line) to display partition information: Show Sample Output


    2
    lsblk --json | jq -c '.blockdevices[]|[.name,.size]'
    mikhail · 2021-12-22 22:31:07 275

  • 1
    sfdisk -d /dev/sda | sfdisk /dev/sdb
    wincus · 2010-02-03 14:49:07 4
  • To get most of you HDD/SSD driver you need to make sure you partition are aligned, if not the speed penalty can be up to 50% slower! this simple one liner will check to see if each partition start sector is divided by 512 you need to change sda with your driver if you find the one of your partitions is not aligned use gparted to move the start sector of the partition to be divided of 512 Show Sample Output


    1
    fdisk -l /dev/sda | grep -E sda[0-9]+ | sed s/*// | awk '{printf ("%s %f ",$1,$2/512); if($2%512){ print "BAD" }else {print "Good"} }' | column -t
    The_IceMan_Blog · 2012-05-18 08:34:36 5
  • Show the UUID-based alternate device names of ZEVO-related partitions on Darwin/OS X. Adapted from the lines by dbrady at http://zevo.getgreenbytes.com/forum/viewtopic.php?p=700#p700 and following the disk device naming scheme at http://zevo.getgreenbytes.com/wiki/pmwiki.php?n=Site.DiskDeviceNames Show Sample Output


    1
    ls /dev/disk* | xargs -n 1 -t sudo zdb -l | grep GPTE_
    grahamperrin · 2012-10-06 20:19:45 5

  • 1
    mount -o sb=98304 /dev/sda5 /mnt/data5
    rugina · 2013-06-25 08:50:44 10
  • XX is your device partition number like /dev/sdc1 . to see how many inodes your partition have type: df --inodes (or df -i) Default formatting with ext4 would create small inode count for the new partition if you need big count of inodes is the fstype news the correct one. in debian you can see which fstype exists as template in: vim /etc/mke2fs.conf if you format default ext for a partition size with 1TB you would get 1 Million inodes (not enough for backupStorages) but if you format with fstype news you would get hunderd of millions of inodes for the partition. you have tune /etc/sysctl.conf also with following sysconfig parameters fs.file-max = XXX fs.nr_open = XXX where XXX is the count of max inodes for whole system


    1
    mkfs.ext4 -T news /dev/sdcXX
    aysadk · 2019-07-02 13:31:23 37
  • Creates a single primary partition starting at sector 0 and extending to the end of the disk. Use with care.


    0
    echo "0,,L" | sfdisk /dev/sdX
    twobitsprite · 2012-04-09 18:36:24 5
  • Another alternative to blkid, lsblk, file -s, cat /proc/paritions, fdisk -l, etc.. Show Sample Output


    0
    fsarchvier probe simple
    0xFF · 2013-04-28 10:16:18 6

  • 0
    sudo dumpe2fs /dev/sda1 | grep superblock
    rugina · 2013-06-25 08:48:49 182

  • -1
    diskutil list
    grahamperrin · 2012-10-06 21:18:27 6
  •  1 2 > 

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Save your terminal commands in bash history in real time
Use this command if you want your terminal commands be saved in your history file in real time instead of waiting until the terminal is closed

Reset terminal that has been buggered by binary input or similar

Check for Firewall Blockage.
This is just one method of checking to see if an IP is blocked via IP tables or CSF. Simple and to the point. Replace xx.xx.xx.xx with the IP you wish to check.

List all authors of a particular git project
This should work even if the output format changes.

list all file extensions in a directory
Just a little simplification.

Find status of all symlinks
The symlinks command can show status of all symbolic links, including which links are dangling, which symlinks point to files on other file systems, which symlinks use ../ more than necessary, which symlinks are messy (e.g. having too many slashes or dots), etc. Other useful things it can do include removing all dangling links (-d) and converting absolute links to relative links (-c). The path given must be an absolute path (which is why I used $(pwd) in the example command).

Get the Volume labels all bitlocker volumes had before being encrypted
Get information of volume labels of bitlocker volumes, even if they are encrypted and locked (no access to filesystem, no password provided). Note that the volume labels can have spaces, but only if you name then before encryption. Renaming a bitlocker partition after being encrypted does not have the same effect as doing it before.

Randomize lines in a file
Works in sort (GNU coreutils) 7.4, don't know when it was implemented but sometime the last 6 years.

show all key and mouse events
for mousevents, move the mouse over the window and click/move etc. usefull for getting mouseKeys, or keyKeys. also usefull for checking if X gets those mouse-events.

Check a directory of PNG files for errors
Useful for checking if a large number of PNG files was downloaded successfully by verifying the built-in CRC checksum. For incomplete files, the command will print: "00002309.png EOF while reading IDAT data ERROR: 00002309.png" The process is very fast; checking 21,000 files of 5MB in size took only five minutes on a 2011 Intel mobile dual-core.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: