Howto cleanly unmount a root filesystem that's using aufsSquash tools don't make correct image for use

Hacker Rank: Array left rotation

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

Where was Karl Mordo in Infinity War?

How do I construct an nxn matrix?

If a druid in Wild Shape swallows a creature whole, then turns back to her normal form, what happens?

What is the difference between ashamed and shamed?

Where is this triangular-shaped space station from?

As a new poet, where can I find help from a professional to judge my work?

Is there any relevance to Thor getting his hair cut other than comedic value?

How do ISS astronauts "get their stripes"?

How to deny access to SQL Server to certain login over SSMS, but allow over .Net SqlClient Data Provider

I can't die. Who am I?

Should I choose Itemized or Standard deduction?

Skis versus snow shoes - when to choose which for travelling the backcountry?

What is the difference between throw e and throw new Exception(e)?

Understanding Kramnik's play in game 1 of Candidates 2018

What is better: yes / no radio, or simple checkbox?

Is my plan for fixing my water heater leak bad?

What am I? I am in theaters and computer programs

Replacement ford fiesta radiator has extra hose

What's the difference between a cart and a wagon?

Can this function be rewritten with a regex?

Make me a metasequence

Can you 'upgrade' leather armor to studded leather armor without purchasing the new armor directly?



Howto cleanly unmount a root filesystem that's using aufs


Squash tools don't make correct image for use













3















Preface: I've made a boot-image that boots up Debian/Ubuntu using SquashFS and aufs.
The image contains a cleaned up debootstrap install, compressed into a squashfs image.



The squashfs image is considered the readonly part of my filesystem.
The local harddrive is considered the writable part of my root filesystem.



All setup of the rootfs is done from initramfs which calls switch_root to boot-up Debian/Ubuntu. The rootfs itself is mounted using aufs on the squash image (ro) and the harddrive (rw).



When the initramfs is running, I check if the harddrive is cleanly unmounted. I make sure it's clean before I mount it by calling 'fsck -Cp' (I know, I shouldn't).



The Problem: The problem that I have, is that the writable part of my root filesystem is never unmounted properly, leaving it (eg, the hdd) in an unclean state.



The base of the problem is obviously that the hdd is in use by the aufs filesystem. The aufs filesystem is obviously in use by the rootfs. Next to that, I figure that the Debian/Ubuntu shutdown procedure must be modified to allow this.



What have I done so far:
I have tried to shutdown by hand, by first going into runlevel 1, and forcing ro-remounts of the rootfs and the hdd, but the hdd is still never unmounted cleanly.



I also changed the way aufs is mounted by adding an option to create the xino file outside the harddrive mount. I never see the file being created, nor can I see any open files on the harddrive using lsof.



Last but not least, I added the harddrive to the fstab of the Ubuntu install to have it recognize it. Didn't change a thing when Debian/Ubuntu shuts down though :(



From the looks of it, I have created a "chicken and egg" problem, as I can't unmount the harddrive without first unmounting the root filesystem, which I need to unmount the harddrive lol.



I haven't got the faintest idea of what commands to run, in order to unmount it properly, so any help is very much appreciated.










share|improve this question














bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






migrated from stackoverflow.com Aug 28 '12 at 12:54


This question came from our site for professional and enthusiast programmers.














  • 1





    Technically speaking this should have been migrated to serverfault, as the question is regarding aufs and the way it't used properly, and not Ubuntu or Debian in specific. I'm already working on images for Redhat, Suse and Slackware. Haven't started on Gentoo or others though. The idea behind it, is that it could be used in low memory/drivespace environments like the Raspberry Pi on which I'm testing it out...

    – djBo
    Aug 31 '12 at 17:36


















3















Preface: I've made a boot-image that boots up Debian/Ubuntu using SquashFS and aufs.
The image contains a cleaned up debootstrap install, compressed into a squashfs image.



The squashfs image is considered the readonly part of my filesystem.
The local harddrive is considered the writable part of my root filesystem.



All setup of the rootfs is done from initramfs which calls switch_root to boot-up Debian/Ubuntu. The rootfs itself is mounted using aufs on the squash image (ro) and the harddrive (rw).



When the initramfs is running, I check if the harddrive is cleanly unmounted. I make sure it's clean before I mount it by calling 'fsck -Cp' (I know, I shouldn't).



The Problem: The problem that I have, is that the writable part of my root filesystem is never unmounted properly, leaving it (eg, the hdd) in an unclean state.



The base of the problem is obviously that the hdd is in use by the aufs filesystem. The aufs filesystem is obviously in use by the rootfs. Next to that, I figure that the Debian/Ubuntu shutdown procedure must be modified to allow this.



What have I done so far:
I have tried to shutdown by hand, by first going into runlevel 1, and forcing ro-remounts of the rootfs and the hdd, but the hdd is still never unmounted cleanly.



I also changed the way aufs is mounted by adding an option to create the xino file outside the harddrive mount. I never see the file being created, nor can I see any open files on the harddrive using lsof.



Last but not least, I added the harddrive to the fstab of the Ubuntu install to have it recognize it. Didn't change a thing when Debian/Ubuntu shuts down though :(



From the looks of it, I have created a "chicken and egg" problem, as I can't unmount the harddrive without first unmounting the root filesystem, which I need to unmount the harddrive lol.



I haven't got the faintest idea of what commands to run, in order to unmount it properly, so any help is very much appreciated.










share|improve this question














bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






migrated from stackoverflow.com Aug 28 '12 at 12:54


This question came from our site for professional and enthusiast programmers.














  • 1





    Technically speaking this should have been migrated to serverfault, as the question is regarding aufs and the way it't used properly, and not Ubuntu or Debian in specific. I'm already working on images for Redhat, Suse and Slackware. Haven't started on Gentoo or others though. The idea behind it, is that it could be used in low memory/drivespace environments like the Raspberry Pi on which I'm testing it out...

    – djBo
    Aug 31 '12 at 17:36
















3












3








3


1






Preface: I've made a boot-image that boots up Debian/Ubuntu using SquashFS and aufs.
The image contains a cleaned up debootstrap install, compressed into a squashfs image.



The squashfs image is considered the readonly part of my filesystem.
The local harddrive is considered the writable part of my root filesystem.



All setup of the rootfs is done from initramfs which calls switch_root to boot-up Debian/Ubuntu. The rootfs itself is mounted using aufs on the squash image (ro) and the harddrive (rw).



When the initramfs is running, I check if the harddrive is cleanly unmounted. I make sure it's clean before I mount it by calling 'fsck -Cp' (I know, I shouldn't).



The Problem: The problem that I have, is that the writable part of my root filesystem is never unmounted properly, leaving it (eg, the hdd) in an unclean state.



The base of the problem is obviously that the hdd is in use by the aufs filesystem. The aufs filesystem is obviously in use by the rootfs. Next to that, I figure that the Debian/Ubuntu shutdown procedure must be modified to allow this.



What have I done so far:
I have tried to shutdown by hand, by first going into runlevel 1, and forcing ro-remounts of the rootfs and the hdd, but the hdd is still never unmounted cleanly.



I also changed the way aufs is mounted by adding an option to create the xino file outside the harddrive mount. I never see the file being created, nor can I see any open files on the harddrive using lsof.



Last but not least, I added the harddrive to the fstab of the Ubuntu install to have it recognize it. Didn't change a thing when Debian/Ubuntu shuts down though :(



From the looks of it, I have created a "chicken and egg" problem, as I can't unmount the harddrive without first unmounting the root filesystem, which I need to unmount the harddrive lol.



I haven't got the faintest idea of what commands to run, in order to unmount it properly, so any help is very much appreciated.










share|improve this question














Preface: I've made a boot-image that boots up Debian/Ubuntu using SquashFS and aufs.
The image contains a cleaned up debootstrap install, compressed into a squashfs image.



The squashfs image is considered the readonly part of my filesystem.
The local harddrive is considered the writable part of my root filesystem.



All setup of the rootfs is done from initramfs which calls switch_root to boot-up Debian/Ubuntu. The rootfs itself is mounted using aufs on the squash image (ro) and the harddrive (rw).



When the initramfs is running, I check if the harddrive is cleanly unmounted. I make sure it's clean before I mount it by calling 'fsck -Cp' (I know, I shouldn't).



The Problem: The problem that I have, is that the writable part of my root filesystem is never unmounted properly, leaving it (eg, the hdd) in an unclean state.



The base of the problem is obviously that the hdd is in use by the aufs filesystem. The aufs filesystem is obviously in use by the rootfs. Next to that, I figure that the Debian/Ubuntu shutdown procedure must be modified to allow this.



What have I done so far:
I have tried to shutdown by hand, by first going into runlevel 1, and forcing ro-remounts of the rootfs and the hdd, but the hdd is still never unmounted cleanly.



I also changed the way aufs is mounted by adding an option to create the xino file outside the harddrive mount. I never see the file being created, nor can I see any open files on the harddrive using lsof.



Last but not least, I added the harddrive to the fstab of the Ubuntu install to have it recognize it. Didn't change a thing when Debian/Ubuntu shuts down though :(



From the looks of it, I have created a "chicken and egg" problem, as I can't unmount the harddrive without first unmounting the root filesystem, which I need to unmount the harddrive lol.



I haven't got the faintest idea of what commands to run, in order to unmount it properly, so any help is very much appreciated.







debian squashfs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 27 '12 at 11:44









djBodjBo

11613




11613





bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






migrated from stackoverflow.com Aug 28 '12 at 12:54


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Aug 28 '12 at 12:54


This question came from our site for professional and enthusiast programmers.










  • 1





    Technically speaking this should have been migrated to serverfault, as the question is regarding aufs and the way it't used properly, and not Ubuntu or Debian in specific. I'm already working on images for Redhat, Suse and Slackware. Haven't started on Gentoo or others though. The idea behind it, is that it could be used in low memory/drivespace environments like the Raspberry Pi on which I'm testing it out...

    – djBo
    Aug 31 '12 at 17:36
















  • 1





    Technically speaking this should have been migrated to serverfault, as the question is regarding aufs and the way it't used properly, and not Ubuntu or Debian in specific. I'm already working on images for Redhat, Suse and Slackware. Haven't started on Gentoo or others though. The idea behind it, is that it could be used in low memory/drivespace environments like the Raspberry Pi on which I'm testing it out...

    – djBo
    Aug 31 '12 at 17:36










1




1





Technically speaking this should have been migrated to serverfault, as the question is regarding aufs and the way it't used properly, and not Ubuntu or Debian in specific. I'm already working on images for Redhat, Suse and Slackware. Haven't started on Gentoo or others though. The idea behind it, is that it could be used in low memory/drivespace environments like the Raspberry Pi on which I'm testing it out...

– djBo
Aug 31 '12 at 17:36







Technically speaking this should have been migrated to serverfault, as the question is regarding aufs and the way it't used properly, and not Ubuntu or Debian in specific. I'm already working on images for Redhat, Suse and Slackware. Haven't started on Gentoo or others though. The idea behind it, is that it could be used in low memory/drivespace environments like the Raspberry Pi on which I'm testing it out...

– djBo
Aug 31 '12 at 17:36












1 Answer
1






active

oldest

votes


















0














You can never unmount root filesystem, sorry -- no matter if you're using squashfs+aufs, or just plain ext2/ext3/ext4...



What you can do is remount it read-only, which is the same from data integrity standpoint. For regular filesystem:



mount -oremount,ro /
sync # initiate writing any pending writes to disk
sleep 5 # and give writes some time to finish.


note that aufs is somewhat different as you should make sure the rw-backing of it still writeable while aufs itself is being put read-only... for example, assuming /mnt/sq/rw is ext4 read-write part of your aufs "/" mount:



 cat /proc/mounts > /etc/mtab # may not be needed if your mtab is symlink or otherwise reflects real situation
fuser -mv / # show debug of what is using this disk and blocking unmount/ro-remount, if anything
auplink / flush
mount -oremount,noxino,noplink,ro /
mount -oremount,sync /mnt/sq/rw
mount -oremount,mod:/mnt/sq/rw=ro /
mount -oremount,ro /mny/sq/rw
sync
sleep 5
cat /proc/mounts
dmesg
sleep 300 # to give you time to read mounts/dmesg info
halt -d -f


in production you obviously won't need debug info...



In short, you flush to disk and disable aufs features that require writing to ext4 overlay, then force ext4 itself to sync and go read-only, so it will be marked as cleanly unmounted next time you boot.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f181353%2fhowto-cleanly-unmount-a-root-filesystem-thats-using-aufs%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can never unmount root filesystem, sorry -- no matter if you're using squashfs+aufs, or just plain ext2/ext3/ext4...



    What you can do is remount it read-only, which is the same from data integrity standpoint. For regular filesystem:



    mount -oremount,ro /
    sync # initiate writing any pending writes to disk
    sleep 5 # and give writes some time to finish.


    note that aufs is somewhat different as you should make sure the rw-backing of it still writeable while aufs itself is being put read-only... for example, assuming /mnt/sq/rw is ext4 read-write part of your aufs "/" mount:



     cat /proc/mounts > /etc/mtab # may not be needed if your mtab is symlink or otherwise reflects real situation
    fuser -mv / # show debug of what is using this disk and blocking unmount/ro-remount, if anything
    auplink / flush
    mount -oremount,noxino,noplink,ro /
    mount -oremount,sync /mnt/sq/rw
    mount -oremount,mod:/mnt/sq/rw=ro /
    mount -oremount,ro /mny/sq/rw
    sync
    sleep 5
    cat /proc/mounts
    dmesg
    sleep 300 # to give you time to read mounts/dmesg info
    halt -d -f


    in production you obviously won't need debug info...



    In short, you flush to disk and disable aufs features that require writing to ext4 overlay, then force ext4 itself to sync and go read-only, so it will be marked as cleanly unmounted next time you boot.






    share|improve this answer






























      0














      You can never unmount root filesystem, sorry -- no matter if you're using squashfs+aufs, or just plain ext2/ext3/ext4...



      What you can do is remount it read-only, which is the same from data integrity standpoint. For regular filesystem:



      mount -oremount,ro /
      sync # initiate writing any pending writes to disk
      sleep 5 # and give writes some time to finish.


      note that aufs is somewhat different as you should make sure the rw-backing of it still writeable while aufs itself is being put read-only... for example, assuming /mnt/sq/rw is ext4 read-write part of your aufs "/" mount:



       cat /proc/mounts > /etc/mtab # may not be needed if your mtab is symlink or otherwise reflects real situation
      fuser -mv / # show debug of what is using this disk and blocking unmount/ro-remount, if anything
      auplink / flush
      mount -oremount,noxino,noplink,ro /
      mount -oremount,sync /mnt/sq/rw
      mount -oremount,mod:/mnt/sq/rw=ro /
      mount -oremount,ro /mny/sq/rw
      sync
      sleep 5
      cat /proc/mounts
      dmesg
      sleep 300 # to give you time to read mounts/dmesg info
      halt -d -f


      in production you obviously won't need debug info...



      In short, you flush to disk and disable aufs features that require writing to ext4 overlay, then force ext4 itself to sync and go read-only, so it will be marked as cleanly unmounted next time you boot.






      share|improve this answer




























        0












        0








        0







        You can never unmount root filesystem, sorry -- no matter if you're using squashfs+aufs, or just plain ext2/ext3/ext4...



        What you can do is remount it read-only, which is the same from data integrity standpoint. For regular filesystem:



        mount -oremount,ro /
        sync # initiate writing any pending writes to disk
        sleep 5 # and give writes some time to finish.


        note that aufs is somewhat different as you should make sure the rw-backing of it still writeable while aufs itself is being put read-only... for example, assuming /mnt/sq/rw is ext4 read-write part of your aufs "/" mount:



         cat /proc/mounts > /etc/mtab # may not be needed if your mtab is symlink or otherwise reflects real situation
        fuser -mv / # show debug of what is using this disk and blocking unmount/ro-remount, if anything
        auplink / flush
        mount -oremount,noxino,noplink,ro /
        mount -oremount,sync /mnt/sq/rw
        mount -oremount,mod:/mnt/sq/rw=ro /
        mount -oremount,ro /mny/sq/rw
        sync
        sleep 5
        cat /proc/mounts
        dmesg
        sleep 300 # to give you time to read mounts/dmesg info
        halt -d -f


        in production you obviously won't need debug info...



        In short, you flush to disk and disable aufs features that require writing to ext4 overlay, then force ext4 itself to sync and go read-only, so it will be marked as cleanly unmounted next time you boot.






        share|improve this answer















        You can never unmount root filesystem, sorry -- no matter if you're using squashfs+aufs, or just plain ext2/ext3/ext4...



        What you can do is remount it read-only, which is the same from data integrity standpoint. For regular filesystem:



        mount -oremount,ro /
        sync # initiate writing any pending writes to disk
        sleep 5 # and give writes some time to finish.


        note that aufs is somewhat different as you should make sure the rw-backing of it still writeable while aufs itself is being put read-only... for example, assuming /mnt/sq/rw is ext4 read-write part of your aufs "/" mount:



         cat /proc/mounts > /etc/mtab # may not be needed if your mtab is symlink or otherwise reflects real situation
        fuser -mv / # show debug of what is using this disk and blocking unmount/ro-remount, if anything
        auplink / flush
        mount -oremount,noxino,noplink,ro /
        mount -oremount,sync /mnt/sq/rw
        mount -oremount,mod:/mnt/sq/rw=ro /
        mount -oremount,ro /mny/sq/rw
        sync
        sleep 5
        cat /proc/mounts
        dmesg
        sleep 300 # to give you time to read mounts/dmesg info
        halt -d -f


        in production you obviously won't need debug info...



        In short, you flush to disk and disable aufs features that require writing to ext4 overlay, then force ext4 itself to sync and go read-only, so it will be marked as cleanly unmounted next time you boot.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jul 6 '14 at 23:49

























        answered Jun 23 '14 at 10:56









        Matija NalisMatija Nalis

        633810




        633810






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f181353%2fhowto-cleanly-unmount-a-root-filesystem-thats-using-aufs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            List of shipwrecks in 1808...

            Is there a lightweight tool to crop images quickly?Cropping Images using Command Line Tools OnlyHow to crop...

            Unit packagekit.service is masked Announcing the arrival of Valued Associate #679: Cesar...