Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Fedora, Knoppix, Slackware, openSuse, and SystemRescueCD
Posts: 9
Rep:
Using parted in a script
I am having to re-image Windows XP Embedded machines that are formatted with fat32. This needs to be unattended, and I am having a problem with parted.
Since we don't know how big the hard drive may be on all the different controllers, the image will be just large enough to hold WinXPE, after imaging the controller, we need to expand the fat32 file system to fill the partition.
The problem is that sometimes parted comes back with an error that says "Warning: File system is reporting XXXXX clusters, not XXXXX clusters." When you use the --script flag, it simply cancels out of this warning instead of continuing with the resize. parted will do the resize correctly when you select ignore, but there in lies the problem. Does anyone know how to script this to always ignore the warning????
I've tired a here-document like this:
parted << eof
ignore
q
eof
It only works when parted does not throw the error. This error does not show up everytime, even on the same machine with the same image over and over again.
I don't know about your problem with parted but, I would be inclined to use scriptable fdisk ( sfdisk ) and tell it to make one partition to fill the drive. For example:
Code:
# For vfat, use C
sfdisk -D /dev/sda1 << EOF
,,C,*
EOF
# For ntfs, use 7
sfdisk -D /dev/sda1 << EOF
,,7,*
EOF
# Format the partition as vfat
/sbin/mkfs.vfat /dev/sda1
# Format the partition quickly for ntfs
/sbin/mkfs.ntfs -Q /dev/sda1 >/dev/null
Distribution: Fedora, Knoppix, Slackware, openSuse, and SystemRescueCD
Posts: 9
Original Poster
Rep:
Thanks Homey, but the issue isn't with the hard drive partitioning, but rather the new image file system v. the partition size.
The controllers are already functioning with WinXP Embedded. But not all of the machines have the same hardware. Depending on the controller, my script will pull the correct image from the server and replace the current WinXP image with our software updates. Because we don't know how big each hard drive is in advance, the new images will be just big enough to hold the Windows image and our software. Once it is on the hard drive, the image file system will have to be re-sized to fill the partition. This is done simply by using parted to "resize" to current size. Done simply if you have someone sitting there re-imaging hundreds of machines by hand.
I think I have it working now, though. I re-ordered some things in my script and using the Here-Document I have had 100% success rate during the initial testing. Before it was 5 of 10 tries. With no real rhyme or reason why it would fail half the time.
It seems odd to me that parted was written to safely resize a partition and has a scripting option, but there is no way to ignore known warnings, and it defaults to "Cancel" in script mode. The machines and images that are formatted NTFS are no problem, because when you use ntfsresize and pass no size arguments, it forces the file system to fill the partition. Why can't parted work that simply? Oh well.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.