OK, that seam to work however it is not exactly the correct solution for me since I need to make it one command to be able to call it from an API I have no name!@(none):/# ntfsresize /dev/sda1 ntfsresize v2012.1.15AR.5 (libntfs-3g) ERROR: Volume is scheduled for check. Run chkdsk /f and please try again, or see option -f. I have no name!@(none):/# chkdsk /f bash: chkdsk: command not found I have no name!@(none):/# I have no name!@(none):/# ntfsresize -f /dev/sda1 ntfsresize v2012.1.15AR.5 (libntfs-3g) Device name : /dev/sda1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 21472604672 bytes (21473 MB) Current device size: 32210026496 bytes (32211 MB) New volume size : 32210022912 bytes (32211 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 9815 MB (45.7%) Collecting resizing constraints ... WARNING: Every sanity check passed and only the dangerous operations left. Make sure that important data has been backed up! Power outage or computer crash may result major data loss! Are you sure you want to proceed (y/[n])? y Schedule chkdsk for NTFS consistency check at Windows boot time ... Resetting $LogFile ... (this might take a while) Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... Syncing device ... Successfully resized NTFS on device '/dev/sda1'. Keresztes Péter-Zoltán zozo@z0z0.tk I haven’t lost my mind, I know exactly where I left it. On 01 Jul 2014, at 20:45, Richard W.M. Jones <rjones@redhat.com> wrote:> [Let's keep everything on the mailing list] > > On Tue, Jul 01, 2014 at 08:37:39PM +0300, Keresztes Péter-Zoltán wrote: >> Hi, I have run the command with virt-rescue and after getting lots of error I get a prompt where I enter the ntfsresize —check /dev/sda1 and I get the following: >> >> I have no name!@(none):/# ntfsresize --check /dev/sda1 >> ntfsresize v2012.1.15AR.5 (libntfs-3g) >> I have no name!@(none):/# > > For comparison, here is the output using ntfs-3g-2014.2.15-1.fc20.x86_64: > > $ guestfish -N fs:ntfs exit > $ virt-rescue --ro -a test1.img > [...] >> <rescue> ntfsresize --check /dev/sda1 > ntfsresize v2014.2.15 (libntfs-3g) >> <rescue> > > So that's basically the same as your output, and indicates that > the ntfsresize command itself is working. > > Now you should try actually resizing the partition in virt-rescue. > Since it is inside ``virt-rescue --ro'' it won't actually alter the > disk image -- the ``--ro'' flag means that libguestfs puts a > protective overlay between the commands in the rescue shell and the > underlying disk image. > > Here is what happens for me: > >> <rescue> ntfsresize /dev/sda1 > ntfsresize v2014.2.15 (libntfs-3g) > Device name : /dev/sda1 > NTFS volume version: 3.1 > Cluster size : 4096 bytes > Current volume size: 104727040 bytes (105 MB) > Current device size: 104727040 bytes (105 MB) > New volume size : 104727040 bytes (105 MB) > Nothing to do: NTFS volume size is already OK. > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > virt-top is 'top' for virtual machines. Tiny program with many > powerful monitoring features, net stats, disk stats, logging, etc. > http://people.redhat.com/~rjones/virt-top
On Tue, Jul 01, 2014 at 08:50:27PM +0300, Keresztes Péter-Zoltán wrote:> OK, that seam to work however it is not exactly the correct solution > for me since I need to make it one command to be able to call it > from an APIUnderstood. What I'm trying to find out is why the ntfsresize utility is failing when it is being run under virt-resize, since it is not printing any error message but is returning a non-zero error code. By running it under virt-rescue, you can test ntfsresize and also see the full errors.> I have no name!@(none):/# ntfsresize /dev/sda1 > ntfsresize v2012.1.15AR.5 (libntfs-3g) > ERROR: Volume is scheduled for check. > Run chkdsk /f and please try again, or see option -f.I think this is the problem. In virt-resize 1.20 and above you can use ``virt-resize --ntfsresize-force'' which has the same effect as passing the -f option to ntfsresize: --ntfsresize-force Pass the --force option to ntfsresize(8), allowing resizing even if the NTFS disk is marked as needing a consistency check. You have to use this option if you want to resize a Windows guest multiple times without booting into Windows between each resize. However I am not sure if this is safe. You will have to ask the ntfs-3g community whether running ntfsresize on a partition that is marked as needing chkdsk is in fact safe, or if you are going to have other problems from doing this. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Actually I have find out that the virt-resize is failing because it’s flagged for a consistency check if I run the command with —ntfsresize-force it works with no issue. Thanks you were be very helpful, actually I would have not find this if you would not ask me to run the other method. Keresztes Péter-Zoltán zozo@z0z0.tk I haven’t lost my mind, I know exactly where I left it. On 01 Jul 2014, at 21:33, Richard W.M. Jones <rjones@redhat.com> wrote:> On Tue, Jul 01, 2014 at 08:50:27PM +0300, Keresztes Péter-Zoltán wrote: >> OK, that seam to work however it is not exactly the correct solution >> for me since I need to make it one command to be able to call it >> from an API > > Understood. What I'm trying to find out is why the ntfsresize utility > is failing when it is being run under virt-resize, since it is not > printing any error message but is returning a non-zero error code. > > By running it under virt-rescue, you can test ntfsresize and also see > the full errors. > >> I have no name!@(none):/# ntfsresize /dev/sda1 >> ntfsresize v2012.1.15AR.5 (libntfs-3g) >> ERROR: Volume is scheduled for check. >> Run chkdsk /f and please try again, or see option -f. > > I think this is the problem. > > In virt-resize 1.20 and above you can use ``virt-resize --ntfsresize-force'' > which has the same effect as passing the -f option to ntfsresize: > > --ntfsresize-force > Pass the --force option to ntfsresize(8), allowing resizing even if > the NTFS disk is marked as needing a consistency check. You have > to use this option if you want to resize a Windows guest multiple > times without booting into Windows between each resize. > > However I am not sure if this is safe. You will have to ask the > ntfs-3g community whether running ntfsresize on a partition that is > marked as needing chkdsk is in fact safe, or if you are going to > have other problems from doing this. > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > libguestfs lets you edit virtual machines. Supports shell scripting, > bindings from many languages. http://libguestfs.org