Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to format partition only (not whole disk) #24

Closed
lucky62 opened this issue Feb 15, 2016 · 11 comments
Closed

Add option to format partition only (not whole disk) #24

lucky62 opened this issue Feb 15, 2016 · 11 comments
Assignees

Comments

@lucky62
Copy link

lucky62 commented Feb 15, 2016

It would be good to have the option to format single partition on partitioned disk.
I know that this will not work with OS X. But it will be useful for peoples using only Linux and Windows.

@JElchison
Copy link
Owner

Hi @lucky62, thanks for your message!

If I'm understanding you correctly, then format-udf can currently do what you're asking: Just invoke with -p none, and the script won't modify the partition table at all. However, format-udf will still attempt to write the UDF file system over the entire disk, which might not be what you want. (That might be a recipe for having a partition table that mismatches the contents of the disk.)

You may be able to use a pre-existing non-entire-disk partition by invoking mkudffs on your own. However, at that point, you don't need this format-udf script at all. :)

Does this help? Please report back on your results if you end up using mkudffs on your own. Good luck!

@lucky62
Copy link
Author

lucky62 commented Feb 15, 2016

When partition is formatted under linux by mkudffs it is not recognized by Windows 7 and probably also other Windows versions. Also when partition is formatted under Windows it is not recognized by Linux. So working script will be very useful.

@JElchison
Copy link
Owner

Hello again,

Sorry, I must not be understanding you. If you use the script as directed (i.e. entire disk), it will work on both Linux and Windows.

The only way to get Windows to recognize UDF drives is to use the entire disk and write a fake MBR. Please see the README.

If I'm missing the point altogether, please forgive me, and explain exactly what you're looking for.

Thanks!

@lucky62
Copy link
Author

lucky62 commented Feb 16, 2016

Hi, sorry for unclear comment.
Your script is working well for entire disk formatting. I have external 2.5" disk 500G in USB 3.0 enclosure and after formatting by your script it is recognized by Windows and Linux and working well.

But my internal disk is partitioned to 3 partitions. One is Windows 7 system partition, second is Linux system partition (multi-boot) and third is data partition shared by both systems. Currently I am using NTFS file system on shared partition. My intention is to format this shared partition as UDF. The problem is that when partition is formatted by mkudffs in Linux then it is not recognized by Windows and vice versa - when partition is formatted in Windows (by format utility in command line), then it is not recognized by Linux. I tried many variations of formatting parameters (blocksize, etc.) - no success. Your script I cannot use, because it is not designed to format single partition.

It would be good to add this option to your script. Most probably you already have the required knowledge for this.

@JElchison
Copy link
Owner

Hi @lucky62, thanks for taking the time to explain. I think I understand now. This is an interesting edge case.

I'm not fully confident that the resultant drive will auto-mount on Windows (or perhaps mount at all). But, I'm willing to code it up if you're willing to be my tester. Deal?

I may be able to get to this as soon as Friday, but no guarantees.

In order for me to ensure that I'm hitting the right target, it's important for me to understand your setup. Is your current partition table MBR or GPT?

@JElchison
Copy link
Owner

For interesting reading, check out this interesting blog post. If the site is still suspended, you can see the latest archived version here. Also, you can read about UDF's design for entire disks here.

@lucky62
Copy link
Author

lucky62 commented Feb 16, 2016

Hi JElchison,
no problem with testing...
My partition table is MBR type.

@JElchison
Copy link
Owner

Hi @lucky62, the ball is in your court! Please clone/test from https://github.com/JElchison/format-udf/tree/dev-single-existing-partition

Please report back with your results. If this meets your liking, I will merge this branch into master and release it.

@lucky62
Copy link
Author

lucky62 commented Feb 20, 2016

Hi,
it looks good. I have tested it in virtual boxes and partition is visible and read/write-able by both linux and win7. Later I will test it on real disk.

Few comments:

  1. When partition was created by fdisk, then I must restart linux, because partition was not recognized by kernel immediately (although was listed by fdisk -l ). Script ended with error - "missing or not block device".
  2. Partition is not recognized by Windows 7 when it is of type 83 (linux). I must change the partition type to 6 (msdos) by fdisk. This is mentioned already somewhere on net. It will be good to change the partition type by your script, if it is not correct (not 6).
  3. Please consider to allow "/dev/" prefix for the device name. So both formats will be possible:
  • without "/dev/" - e.g. sdb|sdb2
  • with "/dev/" - e.g. /dev/sdb|/dev/sdb2

I see that "/dev/$DEVICE" pattern is used many times in your script so I think better is to check at the beginning if has the "/dev/" prefix and add it if not. Then you can use simple "$DEVICE" intead of "/dev/$DEVICE".

@lucky62
Copy link
Author

lucky62 commented Feb 20, 2016

Hi again,
I have script tested on fhysical disk and result is different. Partition formatted by script is not recognized by Windows 7 (listed as RAW partition in Disk Management). May be the disk geometry is different in Windows than in linux. How can I check this?

@JElchison
Copy link
Owner

Hi @lucky62, thanks for the quick turnaround! I will merge/release later today.

I will try to address your comments in order.

First comment:

  1. If you're seeing a message about your device not being "block special", then it's failing the POSIX test -b check. Cases like that are usually indicative that you've fat-fingered the device identifier, or the OS has fallen out of sync with what's connected to your computer. The latter can sometimes be remedied by calling partprobe (if you have gparted installed). However, recall that what you're trying to accomplish is a bit underhanded to begin with: Once you format a partition as UDF, the drive contents no longer match the partition table. There is no way around this, as there is no such partition identifier for UDF. In your case, the partition identifier appears to be set to msdos (formerly linux); note that neither of these are udf, as this udf type doesn't exist. This is a necessary evil, and one of the reasons why I urged you caution when you first made this feature request. Bottom line: UDF was not designed to do what you're trying to do. Here be dragons...
  2. Sadly, you've stumbled into the trap I thought you would. :) As mentioned earlier in this thread, as well in the preceding paragraph, Windows will have trouble mounting a UDF partition, because there is no udf partition type. As you've already seen, you can attempt to trick it by setting the partition type to something Windows does recognize, and hope for the best. Modifying the existing partition table is outside of the scope for this tool. When formatting an entire device, I'm writing a brand new partition table, since I'm in complete control. However, modifying someone else's carefully-crafted boot sector is risky business, and I can't see sensibly automating that. My best advice for you would be to use your favorite tool to manually modify your partition table (as you already have).
  3. I've added your feature request as Let <device> parameter have '/dev/' prefix #25.

Second comment:

The disk geometry is tied to your physical device, and will not differ between operating systems. You're likely running into item 2 above. It's probably behaving differently because of the partition table mismatch. I recommend attempting to change the partition type to FAT32 (0b).

Another possibility is that your HDD doesn't have the standard block size of 512. Windows has been known to choke on certain devices. See the issue history for more info.

Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants