parted command line not get the same result
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I created my virtual disk (1024MB):
~$ dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
Case 1:
Now I'm going to configure it with inside parted to Partitioning / formatting MyDrive.img:
~$ parted MyDrive.img
(parted) mklabel msdos
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
Result:
(parted) print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Verifying partition:
~$ sudo losetup loop1 MyDrive.img
~$ sudo -H gparted /dev/loop1
So far, so good. Now the problem...
Case 2:
If I want to launch the "parted" from command line (in terminal; outside parted), with the same commands, i do not get the same result:
~$ parted -s MyDrive.img mklabel msdos
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024
~$ parted -s MyDrive.img align-check optimal 1
~$ parted -s MyDrive.img set 1 lba on
Out:
~$ parted -s MyDrive.img print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Problem: Missing NTFS and LBA (The same thing happens with ext3, ext4, etc)
Cause:
~$ parted -s MyDrive.img mklabel msdos # Works
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024 # Not Work
~$ parted -s MyDrive.img align-check optimal 1 # Works
~$ parted -s MyDrive.img set 1 lba on # Not Work
Question:
How to correctly execute "parted" with option "-s" (--script) directly from command line in terminal (case 2) to get the same output (Case 1)?
Thanks
linux parted
add a comment |Â
up vote
3
down vote
favorite
I created my virtual disk (1024MB):
~$ dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
Case 1:
Now I'm going to configure it with inside parted to Partitioning / formatting MyDrive.img:
~$ parted MyDrive.img
(parted) mklabel msdos
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
Result:
(parted) print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Verifying partition:
~$ sudo losetup loop1 MyDrive.img
~$ sudo -H gparted /dev/loop1
So far, so good. Now the problem...
Case 2:
If I want to launch the "parted" from command line (in terminal; outside parted), with the same commands, i do not get the same result:
~$ parted -s MyDrive.img mklabel msdos
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024
~$ parted -s MyDrive.img align-check optimal 1
~$ parted -s MyDrive.img set 1 lba on
Out:
~$ parted -s MyDrive.img print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Problem: Missing NTFS and LBA (The same thing happens with ext3, ext4, etc)
Cause:
~$ parted -s MyDrive.img mklabel msdos # Works
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024 # Not Work
~$ parted -s MyDrive.img align-check optimal 1 # Works
~$ parted -s MyDrive.img set 1 lba on # Not Work
Question:
How to correctly execute "parted" with option "-s" (--script) directly from command line in terminal (case 2) to get the same output (Case 1)?
Thanks
linux parted
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I created my virtual disk (1024MB):
~$ dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
Case 1:
Now I'm going to configure it with inside parted to Partitioning / formatting MyDrive.img:
~$ parted MyDrive.img
(parted) mklabel msdos
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
Result:
(parted) print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Verifying partition:
~$ sudo losetup loop1 MyDrive.img
~$ sudo -H gparted /dev/loop1
So far, so good. Now the problem...
Case 2:
If I want to launch the "parted" from command line (in terminal; outside parted), with the same commands, i do not get the same result:
~$ parted -s MyDrive.img mklabel msdos
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024
~$ parted -s MyDrive.img align-check optimal 1
~$ parted -s MyDrive.img set 1 lba on
Out:
~$ parted -s MyDrive.img print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Problem: Missing NTFS and LBA (The same thing happens with ext3, ext4, etc)
Cause:
~$ parted -s MyDrive.img mklabel msdos # Works
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024 # Not Work
~$ parted -s MyDrive.img align-check optimal 1 # Works
~$ parted -s MyDrive.img set 1 lba on # Not Work
Question:
How to correctly execute "parted" with option "-s" (--script) directly from command line in terminal (case 2) to get the same output (Case 1)?
Thanks
linux parted
I created my virtual disk (1024MB):
~$ dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
Case 1:
Now I'm going to configure it with inside parted to Partitioning / formatting MyDrive.img:
~$ parted MyDrive.img
(parted) mklabel msdos
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
Result:
(parted) print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Verifying partition:
~$ sudo losetup loop1 MyDrive.img
~$ sudo -H gparted /dev/loop1
So far, so good. Now the problem...
Case 2:
If I want to launch the "parted" from command line (in terminal; outside parted), with the same commands, i do not get the same result:
~$ parted -s MyDrive.img mklabel msdos
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024
~$ parted -s MyDrive.img align-check optimal 1
~$ parted -s MyDrive.img set 1 lba on
Out:
~$ parted -s MyDrive.img print
Model: (file)
Disk /home/user/test/MyDrive.img: 1074MB
Sector size (logical / physical): 512B / 512B
Table of partitions: msdos
Disk Flags:
Start Number End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Problem: Missing NTFS and LBA (The same thing happens with ext3, ext4, etc)
Cause:
~$ parted -s MyDrive.img mklabel msdos # Works
~$ parted -s MyDrive.img mkpart primary NTFS 1 1024 # Not Work
~$ parted -s MyDrive.img align-check optimal 1 # Works
~$ parted -s MyDrive.img set 1 lba on # Not Work
Question:
How to correctly execute "parted" with option "-s" (--script) directly from command line in terminal (case 2) to get the same output (Case 1)?
Thanks
linux parted
edited Mar 23 at 12:33
asked Mar 22 at 22:47
user4839775
9111
9111
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
parted
uses odd units by default, so it's better to specify it.
(parted) unit MiB
or
(parted) mkpart ... 1MiB 1024MiB
There is no need to do an alignment check if you know your partition starts at 1MiB
.
The set 1 lba on
command actually changes the partition type to Linux. That might come as a bit of a surprise, but it's normal for parted
's set
to change partition types (other options are raid
, lvm
, ...).
Other than that detail, the result of your operations are completely identical. The difference in output is merely an optical problem.
It might be a remnant of old (*) If you want the parted
that used to create the filesystems themselves, instead of partitions only.ntfs
to stick, you actually have to mkntfs
one.
Your interactive method:
# dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
I create a copy of it at this point so we can check and compare the other method:
(parted) ^Z
[1]+ Stopped parted MyDrive.img
# cp MyDrive.img MyDrive-Copy.img
# fg
Onwards:
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
1 aligned
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Shows ntfs
and lba
but print it again and it's gone:
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Your 2nd method using terminal commands, performed on the copy:
# parted MyDrive-Copy.img mkpart primary NTFS 1 1024
# parted MyDrive-Copy.img align-check optimal 1
1 aligned
# parted MyDrive-Copy.img print
Model: (file)
Disk /dev/shm/MyDrive-Copy.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Are there actually any differences?
# cmp -l MyDrive.img MyDrive-Copy.img && echo Identical || echo Different
Identical
(Without the copy method, they would have different disk identifiers as it's random every time you mkpart
. With GPT partitions, each individual partition would also have a unique PARTUUID so the method does not apply to other partitioning schemes, or rather you have to check what the differing bytes represent.)
So, you do get the same result after all, unless the commands are different (there was no set
in your first example).
(*)
To make the confusion perfect, after mkntfs
on the partition, parted
detects NTFS to be present and set 1 lba on
does not set Linux as partition type anymore. This also means with random data on the disk you might get random results in your partition table.
So there may be a point to specifying NTFS when you mkpart
after all. parted
remembers this type for the current session and acts accordingly when picking partition types. Translated to the terminal, it might be best to do it all in one command.
# parted MyDrive.img
mklabel msdos
mkpart primary NTFS 1 1024
set 1 lba on
align-check optimal 1
print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
We're not on the same page here.parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up withmkfs
. It is a different story withgparted
. Withlosetup
you might need--partscan
to see/dev/loopXpY
partition devices and then actually runmkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.
â frostschutz
Mar 23 at 0:24
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
parted
uses odd units by default, so it's better to specify it.
(parted) unit MiB
or
(parted) mkpart ... 1MiB 1024MiB
There is no need to do an alignment check if you know your partition starts at 1MiB
.
The set 1 lba on
command actually changes the partition type to Linux. That might come as a bit of a surprise, but it's normal for parted
's set
to change partition types (other options are raid
, lvm
, ...).
Other than that detail, the result of your operations are completely identical. The difference in output is merely an optical problem.
It might be a remnant of old (*) If you want the parted
that used to create the filesystems themselves, instead of partitions only.ntfs
to stick, you actually have to mkntfs
one.
Your interactive method:
# dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
I create a copy of it at this point so we can check and compare the other method:
(parted) ^Z
[1]+ Stopped parted MyDrive.img
# cp MyDrive.img MyDrive-Copy.img
# fg
Onwards:
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
1 aligned
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Shows ntfs
and lba
but print it again and it's gone:
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Your 2nd method using terminal commands, performed on the copy:
# parted MyDrive-Copy.img mkpart primary NTFS 1 1024
# parted MyDrive-Copy.img align-check optimal 1
1 aligned
# parted MyDrive-Copy.img print
Model: (file)
Disk /dev/shm/MyDrive-Copy.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Are there actually any differences?
# cmp -l MyDrive.img MyDrive-Copy.img && echo Identical || echo Different
Identical
(Without the copy method, they would have different disk identifiers as it's random every time you mkpart
. With GPT partitions, each individual partition would also have a unique PARTUUID so the method does not apply to other partitioning schemes, or rather you have to check what the differing bytes represent.)
So, you do get the same result after all, unless the commands are different (there was no set
in your first example).
(*)
To make the confusion perfect, after mkntfs
on the partition, parted
detects NTFS to be present and set 1 lba on
does not set Linux as partition type anymore. This also means with random data on the disk you might get random results in your partition table.
So there may be a point to specifying NTFS when you mkpart
after all. parted
remembers this type for the current session and acts accordingly when picking partition types. Translated to the terminal, it might be best to do it all in one command.
# parted MyDrive.img
mklabel msdos
mkpart primary NTFS 1 1024
set 1 lba on
align-check optimal 1
print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
We're not on the same page here.parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up withmkfs
. It is a different story withgparted
. Withlosetup
you might need--partscan
to see/dev/loopXpY
partition devices and then actually runmkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.
â frostschutz
Mar 23 at 0:24
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
add a comment |Â
up vote
1
down vote
accepted
parted
uses odd units by default, so it's better to specify it.
(parted) unit MiB
or
(parted) mkpart ... 1MiB 1024MiB
There is no need to do an alignment check if you know your partition starts at 1MiB
.
The set 1 lba on
command actually changes the partition type to Linux. That might come as a bit of a surprise, but it's normal for parted
's set
to change partition types (other options are raid
, lvm
, ...).
Other than that detail, the result of your operations are completely identical. The difference in output is merely an optical problem.
It might be a remnant of old (*) If you want the parted
that used to create the filesystems themselves, instead of partitions only.ntfs
to stick, you actually have to mkntfs
one.
Your interactive method:
# dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
I create a copy of it at this point so we can check and compare the other method:
(parted) ^Z
[1]+ Stopped parted MyDrive.img
# cp MyDrive.img MyDrive-Copy.img
# fg
Onwards:
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
1 aligned
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Shows ntfs
and lba
but print it again and it's gone:
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Your 2nd method using terminal commands, performed on the copy:
# parted MyDrive-Copy.img mkpart primary NTFS 1 1024
# parted MyDrive-Copy.img align-check optimal 1
1 aligned
# parted MyDrive-Copy.img print
Model: (file)
Disk /dev/shm/MyDrive-Copy.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Are there actually any differences?
# cmp -l MyDrive.img MyDrive-Copy.img && echo Identical || echo Different
Identical
(Without the copy method, they would have different disk identifiers as it's random every time you mkpart
. With GPT partitions, each individual partition would also have a unique PARTUUID so the method does not apply to other partitioning schemes, or rather you have to check what the differing bytes represent.)
So, you do get the same result after all, unless the commands are different (there was no set
in your first example).
(*)
To make the confusion perfect, after mkntfs
on the partition, parted
detects NTFS to be present and set 1 lba on
does not set Linux as partition type anymore. This also means with random data on the disk you might get random results in your partition table.
So there may be a point to specifying NTFS when you mkpart
after all. parted
remembers this type for the current session and acts accordingly when picking partition types. Translated to the terminal, it might be best to do it all in one command.
# parted MyDrive.img
mklabel msdos
mkpart primary NTFS 1 1024
set 1 lba on
align-check optimal 1
print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
We're not on the same page here.parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up withmkfs
. It is a different story withgparted
. Withlosetup
you might need--partscan
to see/dev/loopXpY
partition devices and then actually runmkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.
â frostschutz
Mar 23 at 0:24
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
parted
uses odd units by default, so it's better to specify it.
(parted) unit MiB
or
(parted) mkpart ... 1MiB 1024MiB
There is no need to do an alignment check if you know your partition starts at 1MiB
.
The set 1 lba on
command actually changes the partition type to Linux. That might come as a bit of a surprise, but it's normal for parted
's set
to change partition types (other options are raid
, lvm
, ...).
Other than that detail, the result of your operations are completely identical. The difference in output is merely an optical problem.
It might be a remnant of old (*) If you want the parted
that used to create the filesystems themselves, instead of partitions only.ntfs
to stick, you actually have to mkntfs
one.
Your interactive method:
# dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
I create a copy of it at this point so we can check and compare the other method:
(parted) ^Z
[1]+ Stopped parted MyDrive.img
# cp MyDrive.img MyDrive-Copy.img
# fg
Onwards:
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
1 aligned
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Shows ntfs
and lba
but print it again and it's gone:
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Your 2nd method using terminal commands, performed on the copy:
# parted MyDrive-Copy.img mkpart primary NTFS 1 1024
# parted MyDrive-Copy.img align-check optimal 1
1 aligned
# parted MyDrive-Copy.img print
Model: (file)
Disk /dev/shm/MyDrive-Copy.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Are there actually any differences?
# cmp -l MyDrive.img MyDrive-Copy.img && echo Identical || echo Different
Identical
(Without the copy method, they would have different disk identifiers as it's random every time you mkpart
. With GPT partitions, each individual partition would also have a unique PARTUUID so the method does not apply to other partitioning schemes, or rather you have to check what the differing bytes represent.)
So, you do get the same result after all, unless the commands are different (there was no set
in your first example).
(*)
To make the confusion perfect, after mkntfs
on the partition, parted
detects NTFS to be present and set 1 lba on
does not set Linux as partition type anymore. This also means with random data on the disk you might get random results in your partition table.
So there may be a point to specifying NTFS when you mkpart
after all. parted
remembers this type for the current session and acts accordingly when picking partition types. Translated to the terminal, it might be best to do it all in one command.
# parted MyDrive.img
mklabel msdos
mkpart primary NTFS 1 1024
set 1 lba on
align-check optimal 1
print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
parted
uses odd units by default, so it's better to specify it.
(parted) unit MiB
or
(parted) mkpart ... 1MiB 1024MiB
There is no need to do an alignment check if you know your partition starts at 1MiB
.
The set 1 lba on
command actually changes the partition type to Linux. That might come as a bit of a surprise, but it's normal for parted
's set
to change partition types (other options are raid
, lvm
, ...).
Other than that detail, the result of your operations are completely identical. The difference in output is merely an optical problem.
It might be a remnant of old (*) If you want the parted
that used to create the filesystems themselves, instead of partitions only.ntfs
to stick, you actually have to mkntfs
one.
Your interactive method:
# dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
I create a copy of it at this point so we can check and compare the other method:
(parted) ^Z
[1]+ Stopped parted MyDrive.img
# cp MyDrive.img MyDrive-Copy.img
# fg
Onwards:
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1
1 aligned
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
Shows ntfs
and lba
but print it again and it's gone:
# parted MyDrive.img
GNU Parted 3.2
Using /dev/shm/MyDrive.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Your 2nd method using terminal commands, performed on the copy:
# parted MyDrive-Copy.img mkpart primary NTFS 1 1024
# parted MyDrive-Copy.img align-check optimal 1
1 aligned
# parted MyDrive-Copy.img print
Model: (file)
Disk /dev/shm/MyDrive-Copy.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary
Are there actually any differences?
# cmp -l MyDrive.img MyDrive-Copy.img && echo Identical || echo Different
Identical
(Without the copy method, they would have different disk identifiers as it's random every time you mkpart
. With GPT partitions, each individual partition would also have a unique PARTUUID so the method does not apply to other partitioning schemes, or rather you have to check what the differing bytes represent.)
So, you do get the same result after all, unless the commands are different (there was no set
in your first example).
(*)
To make the confusion perfect, after mkntfs
on the partition, parted
detects NTFS to be present and set 1 lba on
does not set Linux as partition type anymore. This also means with random data on the disk you might get random results in your partition table.
So there may be a point to specifying NTFS when you mkpart
after all. parted
remembers this type for the current session and acts accordingly when picking partition types. Translated to the terminal, it might be best to do it all in one command.
# parted MyDrive.img
mklabel msdos
mkpart primary NTFS 1 1024
set 1 lba on
align-check optimal 1
print
Model: (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1024MB 1023MB primary ntfs lba
edited Mar 23 at 0:10
answered Mar 22 at 23:17
frostschutz
24.4k14774
24.4k14774
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
We're not on the same page here.parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up withmkfs
. It is a different story withgparted
. Withlosetup
you might need--partscan
to see/dev/loopXpY
partition devices and then actually runmkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.
â frostschutz
Mar 23 at 0:24
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
add a comment |Â
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
We're not on the same page here.parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up withmkfs
. It is a different story withgparted
. Withlosetup
you might need--partscan
to see/dev/loopXpY
partition devices and then actually runmkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.
â frostschutz
Mar 23 at 0:24
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
Very interesting the answer and contributes a lot to the understanding of the functioning of "parted", however, the question has not yet been answered. If you read carefully, the question is about how to correctly execute the "parted -s" command
â user4839775
Mar 22 at 23:45
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
I consider it answered. Added a print to the last example.
â frostschutz
Mar 23 at 0:11
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
Already execute your suggestion. I even mounted the partition (sudo losetup loop1 MyDisk.img) and verified it (sudo -H gparted /dev/loop1) and there is no NTFS partition (or ext4, etc)
â user4839775
Mar 23 at 0:15
We're not on the same page here.
parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up with mkfs
. It is a different story with gparted
. With losetup
you might need --partscan
to see /dev/loopXpY
partition devices and then actually run mkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.â frostschutz
Mar 23 at 0:24
We're not on the same page here.
parted
does not create filesystems (it used to have filesystem handling but not anymore), you have to follow it up with mkfs
. It is a different story with gparted
. With losetup
you might need --partscan
to see /dev/loopXpY
partition devices and then actually run mkntfs /dev/loopXpY
. I understood your question to be about the difference in parted print output so my answer is mostly referring to that.â frostschutz
Mar 23 at 0:24
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
Look at this unix.stackexchange.com/questions/433449/â¦
â user4839775
Mar 25 at 17:50
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432958%2fparted-command-line-not-get-the-same-result%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password