Tag Info

Hot answers tagged

67

blockdev --getsize64 /dev/sda returns size in bytes. blockdev --getsize /dev/sda returns size in sectors.


30

fdisk doesn't understand the partition layout used by my Mac running Linux, nor any other non-PC partition format. (Yes, there's mac-fdisk for old Mac partition tables, and gdisk for newer GPT partition table, but those aren't the only other partition layouts out there.) Since the kernel already scanned the partition layouts when the block device came into ...


21

This is the size of space on the disk that is used to store the meta information for the directory (i.e. the table of files that belong to this directory). If it is i.e. 1024 this means that 1024 bytes on the disk are used (it always allocate full blocks) for this purpose.


13

It seems that you have a lot more files than normal expectation. I don't know whether there is a solution to change the inode table size dynamically. I'm afraid that you need to back-up your data, and create new filesystem, and restore your data. To create new filesystem with such a huge inode table, you need to use '-N' option of mke2fs(8). I'd ...


11

If you are scripting downloads, you should consider using curl instead. Wget can parse output and recursively fetch whole sites, but curl has way more options relating to the actual download of a specific file. Here is the relevant option in the man page: --max-filesize Specify the maximum size (in bytes) of a file to download. If the file ...


9

If your program doesn't need to write any OTHER files that would be larger than this limit, you can inform the kernel of this limit using ulimit. Before you run your command, run this to setup a 200MB file size limit for all process run in your current shell session: ulimit -f $((200*1024)) This will protect your system but it might be jaring for the ...


9

The dot file, like every directory, contains a list of names for the files in this directory and their inode numbers. So if you once had lots of files in that directory (not unlikely for a "tmp" directory) that would have made the directory entry grow to this size. After the files are gone, the file system doesn't automatically shrink the directory file ...


8

If your application (ie. run_program) does not support limiting the size of the log file, then you can check the file size periodically in a loop with an external application or script. You can also use logrotate(8) to rotate your logs, it has size parameter which you can use for your purpose: With this, the log file is rotated when the specified size ...


8

find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} +


8

How about: fdisk -l This will give you a list of all your disks with their respective capacity, usage, and more.


8

This does the whole job in one go - in all child directories, all in a single stream without any filename problems. It'll copy from smallest to largest every file you have. You will need to mkdir ${DESTINATION} if it doesn't already exist. find . ! -type d -print0 | du -b0 --files0-from=/dev/stdin | sort -zk1,1n | sed -zn 's/^[^0-9]*[0-9]*[^.]*//p' | tar ...


8

You can just do the whole thing with (GNU) find and sort, no need for du: $ find . -iname '*png' -printf '%s %p\n' | sort -rn 68109 ./7.png 21751 ./2.png 21751 ./1.png 5393 ./6.png 2542 ./5.png 1717 ./4.png 1003 ./3.png 878 ./10.png 793 ./9.png 587 ./8.png


7

A directory reserves 4096 bytes (at minimum) for meta-data about itself and its contents. Also, 4096 bytes is the default allocation unit (block) for ext2/ext3/ext4 filesystem and therefor a directory cannot be any smaller. On different filesystems you might find directories with different default sizes, that is due to the default block size of the ...


7

You can use the unzip utility with the -v flag: unzip -v files.zip Archive: files.zip Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 0 Stored 0 0% 11-23-2011 15:02 00000000 file1 0 Stored 0 0% 11-23-2011 15:02 00000000 file2 -------- ...


7

Virtualbox images can be resized from outside Virtualbox. Run this command on the VDI: VBoxManage modifyhd SLACK.vdi --resize 100000 That last number is the size in MiB.


6

The -a in an explicit AND operator that allows you to conjoin two primaries. In this case creating a range using -size. find . -size +386b -a -size -390b -exec rm -f {} \; Note the size is a numeric argument that can optionally be prepended with + and -. From man 1 find: Numeric arguments can be specified as +n for greater than n, -n ...


6

Create an extended partition spanning the new free space, and create a logical partition inside it. (You could create a primary partition, but that would reduce your options later, because of the limit of 4 primary partitions or 3 primary and one extended.) You can do this with fdisk or cfdisk or parted. Set the type of the new partition to 8e (“Linux ...


6

Using sgdisk You can use sgdisk to print detailled information: sgdisk --print <device> […] Disk /dev/sdb: 15691776 sectors, 7.5 GiB Logical sector size: 512 bytes […] When you multiply the number of sectors with the sector size you get the exact byte count that should match the output of dd. Using /sys directly You can also get those numbers ...


5

If you want to use wget, here is a way to test the size of the file without downloading: wget --spider $URL 2>&1 | awk '/Length/ {print $2}' where $URL is the URL of the file you want to download, of course. So you can condition your script based on the output. such as: { [ $(wget --spider $URL 2>&1 | awk '/Length/ {print $2}') -lt ...


5

You may create a new filesystem image, mount it using loop device and put the log file on that filesystem: dd if=/dev/zero of=./200mb.img bs=1024 count=200000 # create new empty 200MB file mkfs.ext2 200mb.img # or ext3, or whatever fits your needs mkdir logs sudo mount -t ext2 -o loop 200mb.img logs # only root can do '-o loop' by default run_program ...


5

You can truncate the output with head: size=$((200*1024*1024-$(stat -c %s myprogram.log))) run_program | head -c ${size} >> myprogram.log


5

You could simply re-create the image "from scratch" with mkisofs. $ mkisofs -o new_image_name /path/to/the/mounted/dvd If you don't have the CD-ROM available anymore, loop-mount the iso image with: $ sudo mount -o loop /media/disk/linux.iso /path/to/the/mounted/dvd (And don't forget to unmount it.) This will not copy boot information from the DVD. If ...


5

Doesn't unzip -l somefile.zip do exactly what you want?


5

A maximum resolution of 800x600 suggests that your X server inside the virtual machine is using the SVGA driver. SVGA is the highest resolution for which there is standard support; beyond that, you need a driver. VirtualBox emulates a graphics adapter that is specific to VirtualBox, it does not emulate a previously existing hardware component like most ...


5

You're using LVM, the logical volume manager. This gives you a lot more flexibility than you would get with simple partitions, but you need to understand how everything fits together. I would start first at the LVM page on Wikipedia, paying special attention to the diagram that shows all the parts. LVM is a stack, with your physical block devices -- ...


5

blockdev --getsize /dev/sda


5

List the files, extract the size in bytes from the list, sort it and count the occurrence of every size: find /my/directory -type f -exec ls -l {} + | cut -d' ' -f5 | sort -n | uniq -c not terribly efficient if there are many many files it may be better to save intermediate results in a temp file, sort it to another temp file, then "uniq" it here I use ...


5

If you want the size of the subdirectories, use du. This will print the size of the subdirectories recursively (-h is for human readable sizes): du -h /media/nss/MBVOL2/TEST1/ If you only want a summary and not each of the results, use -s: du -sh /media/nss/MBVOL2/TEST1/ If you want the size of the directories regarding the atime condition of your ...



Only top voted, non community-wiki answers of a minimum length are eligible