Hot answers tagged

17

That link you posted looks like a very ugly hack type solution. However, according to the man page, gdisk, which is used to convert MBR -> GPT, also has an option in the "recovery & transformation" menu to convert GPT -> MBR; the g key will: Convert GPT into MBR and exit. This option converts as many partitions as possible into MBR form, ...


12

Partprobe calls the BLKRRPART ioctl, which is documented in, err, include/linux/fs.h, and beyond that the kernel source (the meat is in rescan_partitions()): #define BLKRRPART _IO(0x12,95) /* re-read partition table */ The easiest way to find this out is to run strace -e raw=ioctl -e open,ioctl partprobe /dev/sdb. I think what you tried with ...


11

Most of the previous respondents are correct when they say that you can usually do what you need with a GPT partition table layout, but since there are valid reasons for wanting to use MBR, I think I will just answer your question instead of assuming you are wrong for asking. To get rid of the GPT, you need to remember that with this format, there is a ...


8

You can do this like this : parted /dev/sdf --script -- mkpart primary 0 -1


7

Use fdisk for drives that are < 2TB and either parted or gdisk for disk > 2TB. The actual difference has to do with the partitioning formats that these tools are manipulating. For disks < 2TB you're often using MBR (Master Boot Record). For disks > 2TB you're using GPT (GUID Partitioning Table). Here's a good article that covers the differences as ...


6

The extended and logical partitions make sense only with msdos partition table. It's only purpose is to allow you to have more than 4 partitions. With GPT, there are only 'primary' partitions and their number is usually limited to 128 (however, in theory there is no upper limit implied by the disklabel format). Note that on GPT none of the partitions could ...


5

Parted prompts and goes into an interactive mode when you do not provide enough information to create the partition with the command. The following will create a partition that spans the entire disk and will not prompt for filesystem type: mkpart primary 1 -1


5

The primary reason to use gparted or parted is if the new disk is bigger than 2TB. But you probably will not be able to effectively set that up from a 32 bit system. If you want to run the new disk from your old system. Stay with a disk smaller than 2TB. You should be able to partition, format and run that from you old computer using fdisk for partitioning. ...


5

Use the command kpartx to create a loopback device that can then be formatted. kpartx -a /path/to/imagefile.img # Presents partitions from the image file mkfs.vfat /dev/mapper/loop0p1 # Format partition 1 mkfs.ext3 /dev/mapper/loop0p2 # Format partition 2 kpartx -d /path/to/imagefile.img # Unmaps the partitions from the image file Related kpartx ...


5

The real limitation is that the fdisk tool in the util-linux package doesn't support GPT-type partition tables, which you can find on any disk. However, they're commonly found on disks greater than 2 GiB, because the old MBR-type partition tables don't support sizes that large. The easiest fix is, as the error suggested, to just use the GNU Parted software ...


5

First, make sure you understand the difference between primary, extended and logical partitions. To create a logical partition, you first need to create the extended partition that will contain it. If there's only one partition on a drive, there's no point in not making it primary. Below I'll give instructions for a logical partition; creating a primary ...


4

For some reason your kernel fails to read the partition table: [ 8775.030291] end_request: I/O error, dev sdb, sector 0 [ 8775.030300] quiet_error: 30 callbacks suppressed [ 8775.030306] Buffer I/O error on device sdb, logical block 0 [ 8775.033781] ldm_validate_partition_table(): Disk read failed. Thus, it can't create devices for partitions as it did ...


4

In my experience fdisk is more powerful (especially in the advanced mode), but it can leave your disk in a somewhat weird state. For example fdisk will allow your partitions to lie out of order unless you specifically tell it to reorder them, most other tools (and unless i'm very mistaken parted is one of them) will make assumptions that you want everything ...


4

I think parted only accepts absolutes, not x+y. You could do it like this: (+ interpreted by shell) # start=1 # size=512 # parted /dev/loop0 unit mib mkpart primary $start $(($start+$size)) # parted /dev/loop0 unit mib print free Model: Loopback device (loopback) Disk /dev/loop0: 1000MiB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk ...


3

parted can print free space. Example (I chose a complicated one on purpose): # parted /dev/sda unit s print free [...] Number Start End Size Type File system Flags 63s 2047s 1985s Free Space 1 2048s 4196351s 4194304s primary fat32 lba 4196352s 4198399s 2048s ...


3

This is easy using parted. The -s option is used for scripting. The following produces the same results as your fdisk line: parted -s /dev/sda mkpart primary NTFS 1 24G


3

You appear to have both a dos and mac partition table on the disk, and parted is recognizing the mac one. You should be able to zap the mac partition table with: sudo dd if=/dev/zero count=1 bs=2 of=/dev/sda


3

You can use the same script logic for parted, but parted has to be invoked via parted -s (don't run interactively). Wheter you can use the exact same commands in your HEREDOC is unknown to me as I don't use parted. Try a manual dry run, note the commands, and put them in the HEREDOC part of your script.


3

If you have a internet connected to you server, it is very easy: # yum -y install parted


3

It turns out that I needed to run the following: sudo update-grub This updated my /boot/grub/grub.cfg file and got rid of the windows 7 option.


3

If resizepart does not work, you might have to resort to rm and mkpart to achieve the same thing. Of course, this would require you to parse the partition table first in order to determine partition type and start offset. Unless you already know the necessary values. After all you had to get the 166016512B from somewhere too. parted has the --machine ...


3

It looks at the data on the partition, similar to what file -s /dev/partition does. If you strace it you should see things like this: lseek(3, 1048576, SEEK_SET) = 1048576 read(3, "\353<\220mkfs.fat\0\2\10..., 512) = 512 A seek to position 1048576 (1 MiB or 2048 sectors) is outside the partition table (it's the start of the first partition), and it ...


2

First of all, make a backup of at least partitions 1, 2 an 4 and the MBR. It is only 55Gb so that shouldn't take that long. The mkpart command takes the filesystem type as an optional parameter after the required partition type: mkpart PART-TYPE [FS-TYPE] START END make a partition and you seem to give the file system type (ext4) as the partition ...


2

It's correct in principle but you might consider reducing it to a single parted call. parted --script /device \ mklabel gpt \ mkpart primary 1MiB 100MiB \ mkpart primary 100MiB 200MiB \ ... Your alignment issue is probably because you use MB instead of MiB. You should not need an actual align-check command when creating partitions on MiB ...


2

Try to align to eMMC erasure block size. It usually equals 0.5, 1, 2, 4, 8 MiB depending on eMMC datasheet. If you find block size alignment too much memory wasting, then stick to the page size, generally found in the range of 4..16 KiB. Try to make partition sizes and borders a multiple of erasure block size, so when file system writes to the first or last ...


2

with parted you can see unallocated space if you use print free parted command, like parted /dev/sda print free. Or issue parted /dev/sda command, and then inside parted type print free. Example # parted /dev/sda GNU Parted 2.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print free Model: DELL PERC H710 (scsi) ...


2

(As hinted by Gilles), you are not working on your USB device. Clue number one is the Model on the output of $ sudo parted /dev/sde -s print Error: /dev/sde: unrecognised disk label Model: (file) <= file! ... Your command: sudo dd count=1 bs=512 if=/dev/zero of=/dev/sde && sync creates a zero filled ...


2

df is already not that bad. df doesn't show the size of the partition, but the size of the filesystem itself. However, what it shows is also the available space, it does not reflect overhead, metadata and such. For an exact value, you need more filesystem specific tools; for example tune2fs -l /dev/device should give you block count, block size and that ...


2

If the partition is larger than the filesystem, you can use resize2fs to expand it: If size parameter is not specified, it will default to the size of the partition. So it'd just be [#]> resize2fs /dev/sdb1


2

You do not need (and should not create) a filesystem for the BIOS boot partition. The BIOS boot partition holds binary code that is directly accessed by GRUB after it has loaded its first stage in the first sector of the boot drive. The partition should be left unused by anything else because accidental corruption of the boot code can occur otherwise. You ...



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