Debian "Live Session User" sets NTFS drive to read only

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

Debian "Live Session User" sets NTFS drive to read only

#1 Post by nooby »

It doesn't help if one boot as root or use single or rescue
the NTFS drive is set as read only and one would need to
know very much of linux CLI terminal code to change it
if it is even possible?

But in Ubuntu that is rather close to Debian then if one
do a cheat boot using the iso and set up grub4dos like this:


title Netrunner 2011 kubuntu frugal iso boot of netrunner-4.0.iso live
find --set-root --ignore-floppies --ignore-cd /netrunner-4.0.iso
kernel /netrunner40/casper/vmlinuz file=/cdrom/preseed/netrunner.seed boot=casper iso-scan/filename=/netrunner-4.0.iso locale=en_US console-setup/modelcode=pc105 console-setup/layoutcode=se noeject noprompt
initrd /netrunner40/casper/initrd.lz


title ArtistX 2011 ubuntu frugal iso boot artistx_1.2_live_dvd_iso_01_06_2012.iso using LM12
find --set-root --ignore-floppies --ignore-cd /artistx/casper/initrd.lz
kernel /artistx/casper/vmlinuz file=/cdrom/preseed/custom.seed boot=casper iso-scan/filename=/artistx.iso locale=en_US console-setup/modelcode=pc105 console-setup/layoutcode=se noeject noprompt
initrd /artistx/casper/initrd.lz



title usu Bulgarian Ubuntu English version 2011 frugal iso boot of usu-7.0.iso
find --set-root --ignore-floppies --ignore-cd /usu-7.0-netbook-i386.iso
kernel /usu/casper/vmlinuz boot=casper iso-scan/filename=/usu-7.0-netbook-i386.iso locale=en_US console-setup/modelcode=pc105 console-setup/layoutcode=se noeject noprompt
initrd /usu/casper/initrd.gz

The trick is to use this code
"find --set-root --ignore-floppies --ignore-cd /usu-7.0-netbook-i386.iso"

And one need to see to it that the .disk hidden dir is not
included. One need the casper and maybe the preseed
but maybe preeseed can be changed or excluded?????

Now what is it in .disk files that allow the permissions
to accept that one write to the ntfs drive that one
boot from.

if one could mimic what the lack of .disk do on Debian
then Pussylinux and other Debian would have almost
same permissions as Puppy have.



title pussylinux Debian test of ntfs boot.
kernel (hd0,2)/live/vmlinuz boot=live config quickreboot noprompt autologin username=root password=pussy
initrd (hd0,2)/live/initrd.img
boot
I use Google Search on Puppy Forum
not an ideal solution though

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

#2 Post by emil »

Problem short:
the frugal install of Debian live (aka Pussy) is on the NTFS partition. It gets mounted very early in the boot process read only and is not remounted read/write.

mounting/unmounting of other rw NTFS partitions is no problem, but the attempt to unmount the root partition leads to "device busy, failure".

I don't know how to solve this, probably it would mean to hack the initrd.img and to check if it is possible to "force" rw of ntfs or ntfs-3g somehow.

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#3 Post by nooby »

Yes that would be the most proper? or logical way
to remaster the initrd.img if that is the one that
set permissions.

Now based on my experiences of Ubuntu. 18 out of 20
tested ubuntu derivatives and the official ubuntu and
LinuxMint 12 too. All these 18 work as the three I
gave example on.

so if one could find out what is different between the debian
and the ubuntu how it set up the permissions.

Maybe it has to do with how they treat sudo so Ubuntu had
to sift out that portion and place it in the .disk files?
or lacking diskfiles it skip the part of initrd that have to do
with setting permission for the live session user?

I have a vague notion or gut feeling that if one boot using
rescue or single on the boot code then maybe one are
allowed to set it up to have the ntfs drive set as read and
write allowed for the live session user too?

But maybe I am wrong but most likely Debian don't want
to share that knowledge or they would have already done
that somewhere?
I use Google Search on Puppy Forum
not an ideal solution though

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#4 Post by nooby »

I have promised to tell how my Acer D250 Netbook
are partitioned.

It has three ntfs partitions. one of them is kind of hidden?
But puppy do see all three of them.

Windows and linux are on the third sda3 and Recovery on
sda2 and the Acer OEM special are on sda1.

What am I supposed to write in CLI to get a more formal
description? I don't remember the code.
I use Google Search on Puppy Forum
not an ideal solution though

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#5 Post by amigo »

mount -o remount,rw name-of-partition

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#6 Post by nooby »

Yes I did something like that some months ago
and it answer that that drive is already busy

sickgut as I remember explained that that is due
to the boot script make it locked to the live session user
so one are not allowed to change that.

But who knows maybe I entered it wrongly or something
but that was the answer I got
I use Google Search on Puppy Forum
not an ideal solution though

gcmartin

NTFS on Pussy

#7 Post by gcmartin »

amigo wrote:mount -o remount,rw name-of-partition
Hi Nooby.

I would take the word of SickGut as gospel. He is the Pussy expert.

But, if you feel uncomfortable with command Amigo offers, do the following and we will help.
Open a Terminal
type "fdisk -l"
post it back here.

We will tailor your mount command for you by changing the "name of partition" to match your configuration so that you can see whether you can mount your NTFS r/w. His command may work in your case. (In fact, we will provide you with 3 mount commands for each of your partitions so that you can see which work and if there's a problem with ANY of your partitions.

Hope this helps

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

#8 Post by emil »

amigo wrote:
mount -o remount,rw name-of-partition
This doesn't work. There are several Squash files and probably an ext2/ext3 savefile mounted on the ntfs partition to form the overlayed filesystem of debian live. If you try to remount then there is the "drive busy" error nooby mentions.

One thing I noticed was that in my case there was a message about "dirty NTFS" filesystem, so it couldn't get rw mounted. I tried to fix this from inside linux, but "ntsfix /dev/sda1" didn't help and I have no windows any more for a proper "chkdsk". But since nooby also has this problem I guess it is mounted ro in every case.

I used this commands to inspect the initrd.img:

Code: Select all

#cd to directory containing initrd.gz - UNZIP
mkdir initrd-tree
cd initrd-tree/
zcat ../initrd.img | cpio -i -d 

#cd again to initrd-tree - ZIP
rm ../initrd.img
find . | cpio -o -H newc | gzip -9 > ../initrd.img
but was not man enough to find the mount command for the "root" partition (is is already mounted by the kernel?) - I think the mounting of the squashfs and the overlay happens in the "live" script inside initrd.img.
Maybe someone with more clue about the linux boot process can give a hint how and where in the this process a forced remount of the ntfs partition would be possible.

8) Thanks
emil
Last edited by emil on Thu 02 Feb 2012, 12:02, edited 1 time in total.

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#9 Post by nooby »

Thanks for all that effort put into this.

It supports my take on it that the Debian Developers are
true to Unix policy of not allowing "Live Session User" to
have the permissions of writing to that drive it boots from.

They would answer something like. "There is no need for
writing to that drive so do a proper install instead!"

But I can be wrong.

Now. Why do I talk about Ubuntu when the topic is Debian?

These two are close enough and have same policy of not
allowing the "Live Session User" what a full install allow.

But they have set it up differently. Ubuntu use casper dir
and Debian use live dir. Ubuntu also have a .disk dir with
three files in it?????? I don't remember exactly but ...

If one exclude that .disk and use my simplified boot
for grub4dos which I gave three examples on then
the script fails to set the permissions so the ntfs drive
one boot from frugally do allow read and write permission.

Which is surprising. The proper thing would be they
stalled the boot giving an error saying that due to
error we will not allow you to use the computer :)

But if one can mimic that failure or error then one
get insight in how they set the drive to be read only!
I use Google Search on Puppy Forum
not an ideal solution though

jbv
Posts: 179
Joined: Sat 01 Jan 2011, 00:22

#10 Post by jbv »

Hi nooby,

Brief reply for now, more in a day or two.

I think you are going to be out of luck. The switches you are using in Grub or whatever are not the magic key in Ubuntu or whatever. The magic key is actually in their equivalent to initrd.img and their vmlinuz

Without getting to high-tech, lost in detail or being 100% dead accurate, what happens at startup is that vmlinuz is loaded. This is a micro-kernel. It's sole job is to load and run initrd.img which in turn creates the initial filesystems in ram and all the "hidden" startup scripts. These scripts then create the real filesystems, load the real files (in our case .squashfs files) and then flip the whole lot over while running in the vmlinuz kernel so that the stuff you loaded then becomes the real kernel and filesystem.

It is sorta like starting a car drag-race in an old Volkswagen and while you're racing down the drag-strip you are also rebuilding the entire car so that when you get to the other end of the 1/4 mile (in under 10 seconds) you're driving a Brabus Mercedes 800E and you didn't notice the transformation.

Pussy is 100% debian-live which you know uses copy-on-write to track changes. Now while you can have caper-directories or special r/w partitions these still aren't really writing back to the boot volume (disk). They are using tricks to fool you into thinking they are writing back to the boot volume. There is a subtle yet very important distinction you need to take a moment to think about and hopefully you will understand. In all instances the operating system itself is actually in RAM and not on the disc (volume). Sure, your casper or whatever partition may be on the same physical drive, but not from the viewpoint of the operating system (and it's core file-system) which is still 100% in ram.

Now, Ubuntu may have weaved some magic such that the physical files are in an uncompressed format and can be seen from WinXP as normal files, although I could _almost_ assure you that when debian or Ubunto see them, they think they are in ram and they probably are. Doing anything otherwise would break the entire copy-on-write mechanism.

Now, I think I've got an idea that may work, that may simulate what Ubuntu do, but it may require you to make some changes. To start with, I would need the output of an "fdisk -l" and then you may need to do some thinking.

If I have got some of the exact details above it is because I am trying to help you understand the debian-live concept, rather than get bogged down in specific detail. If you already understand this fully, then I'm sorry if this comes across as condescending.

PS. with work commitments and my desire to sort some of my own issues at the moment, please do not think I'm ignoring you if I don't reply the same or next day.

Oh ... gcmartin - I don't think that sickgut would mind me saying that there are a lot of other people playing with pussy that know more about linux and debian-live than he does. For the record, I am NOT one of them, but I don't think sickgut would consider himself to be the supreme holder of all knowledge on pussy (which is really just debian-live) with some stuff chucked on top.

Cheers

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#11 Post by nooby »

Sickgut should answer himself but that is how I remember
is his view of himself too. That he learn from the feedback
and test out things so I trust this is true.
I don't think that sickgut would mind me saying
that there are a lot of other people playing with pussy
that know more about linux and debian-live than he does.
Nothing wrong with that at all. Developers should learn from
each other so just go for it.

Thanks jbv, let it take the time you need and like Barry
say on his blog. He is in it for the fun of testing out things
and to solve coding problems because one learn and that
can be very fun doing.

Even I who almost never learn or remember what I learn
find it very fun when I manage to boot something and
use google and find I am among the few that could do it.

Just kidding :)

copy-on-write Ooops new term to me.

To be fair I should read up on it but my experience is
that I almost never get what such texts say. But sure
I can give it a try.

My extreme wild guess is that Ubuntu has placed part
of the scripts in the .disk hidden directory.

I trust that Debian have all their scripts in the proper place.

So when I "cheat" boot ubuntu in iso frugal style and
make .disk unavailable them I find a loop hole to the
protection that Ubuntu want to set up.

Most likely part of that protection is placed in the files
in the .disk directory so when these are not there physically then the script is set up to give priority
to let the human at least have a booted system.

The Dev was not aware of that that allowed us noobs
to boot using grub4dos and using the iso and that way
get permissions to write to the ntfs we boot from

something they most likely try to protect to not be
possible using these hidden files in the .disk directory.

Why else make them hidden? I try to list them.
I use the LinuxMint 12 as example files are:
base_installable
casper-uuid-generic
cd_type
info
release_notes_url

None of these names gives me any clue that they
would include codes that perform some "Live Session User" setting permissions for the ntfs drive to be "busy"
by the boot process and impossible to change from
within the system.

So I may be totally wrong about these scripts.
Someone savvy would need to go through exactly what
the lack of these files trigger the scripts to not care about
setting the ntfs drive to be forever busy and not giving
permission to unmount it and then remount it.

I just know that if one include the directory then
the boot fails.

I could rename all of them and then change the names
back one at a step to test exactly where the code is.
Maybe even test to have the dir there renamed and see
if the script find the right file inside despite having wrong
name :) I am too lazy to open the files and read them
in case they have many many lines of code.

Sometimes I wonder if the .disk is so magic that it can
even be empty and that would allow the script to set
the ntfs as read only. One never know.

The cool or scary thing is that I have written about this
on Ubuntu and Linux Mint forum and on LinuxQuestion
and none of the Devs or anybody else care about it.

These people are extremely at it to protect the newbie
from being able to write to teh ntfs hd so their total
silence must indicate they are working 24/7 behind
the scenes to rebuild the loop hole and do a upgrade
that force the hd to be only read and not write and read.

That it takes this long time could indicate I 've found
something they never anticipated or it just means they
hate to give a total noob any response so they rather
ignore that I found this breach of security.

The good thing about it is that it points out that
Debian should be able to easily change to being able
to do easy "cheat" iso booting too if one know how
to patch that script.
I use Google Search on Puppy Forum
not an ideal solution though

jbv
Posts: 179
Joined: Sat 01 Jan 2011, 00:22

#12 Post by jbv »

Hi nooby,

Not so fast - slow down a bit - for your sake.

You cannot just copy a directory or files from Ubuntu into Debian and expect them to work. Ubuntu may be based on Debian, but it is so different that it is not the same.

I don't know what is in the .disc directory although that won't make any difference. Whatever is there will not do anything in Debian, although most importantly whatever Ubuntu are doing happens while the kernel is loading.

This means there will not be anywhere that you can just replace a file or whatever. This is what I was trying to explain above. Obviously not well enough though.

Can you please post the results of "fdisk -l"

Cheers

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#13 Post by nooby »

Yes I do get that. I just tried to explain that
the solution lies there somewhere
result of sh-4.1# fdisk -l

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 1567 12586896 27 Unknown
/dev/sda2 * 1568 1580 104422+ 7 HPFS/NTFS
/dev/sda3 1581 30402 231506210 7 HPFS/NTFS
sh-4.1#

Puppy tells me that /dev/sda1 1 1567 12586896 27 Unknown is not unknown but ntfs too.
It is the Acer OEM where they have registration of
the Acer computer at their site and most likely script
for doing back up copies to an external CD or something

Sda2 is the recovery partition. and sda3 is the one
used for both Ms Win 7 and puppy etc.
I use Google Search on Puppy Forum
not an ideal solution though

jbv
Posts: 179
Joined: Sat 01 Jan 2011, 00:22

#14 Post by jbv »

Thanks nooby. I guess you have a "boot manager" installed on /dev/sda3 (or NTFC "c" drive) that intercepts the boot and you choose if it is to boot into WinWhatever or Pussy. Is that correct?

What do you use as a boot manager?
What version of Windows are you using?

How much free space is left on "c" drive (just use Windows to tell you) ?

Cheers

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#15 Post by nooby »

I use grub4dos the one we have on puppy menu.


title pussylinux test
kernel (hd0,2)/live/vmlinuz boot=live config persistent quickreboot noprompt autologin username=root password=pussy
initrd (hd0,2)/live/initrd.img
boot
What version of Windows are you using?

How much free space is left on "c" drive (just use Windows to tell you) ?
No I don't want to start up Win, I have not used that one
for a year. it is there for to be able to upgrade my three
Smartphones so I don't want to touch it until I really must.

I have win7 and I have some 40GB free
but
I will not resize it or do any partition
due to the recovery is dependent on
a hashed sum that describe the untouched drive.

As soon as one change the size the hashed number
will misfit and thus the recovery get destroyed.
I use Google Search on Puppy Forum
not an ideal solution though

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

#16 Post by emil »

nooby I wonder if you could try a little experiment. The reason is that the initrd and vmlinuz need not to be in the same "live" directory than the squahsfs.

During boot the initrd.img searches all partitions drives for the folder live and picks it up in order to load the squashfs for overlay. You could make a folder /boot on sda3 with initrd.img and vmlinuz and shift the folder live to e.g. sda1 (/live will get picked up on any partition)

then you could try to boot with

Code: Select all

title pussylinux test
kernel (hd0,2)/boot/vmlinuz boot=live config persistent quickreboot noprompt autologin username=root password=pussy
initrd (hd0,2)/boot/initrd.img
boot 
I wonder which of the partitions stays read only...

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#17 Post by nooby »

Yes why not maybe that lock sda1 but not sda3.
I don't want to place things on sda1 though but
most likely nothing bad happens. I will look how big
size is left there. Hold your breath while I look :)

I did try very many variations but unfortunately
there is a boot dir for windows there and Debian
seems to not be able to stay in the boot I made
despite that I renamed the BOOT to BOOTold
it still took things from that one and loaded them

so it failed. I tested to have live even on sda1
but it still took things from the BOOTold
even when I only had a live there and no boot
I use Google Search on Puppy Forum
not an ideal solution though

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#18 Post by nooby »

Not that I really want to use usb flash memories
but if one boot from that one but have live on the internal
hd that is ntfs would that work?

I ahve pussy now on a usb and that one do boot and do
allow me to write on the internal HD IIRC that is.

I am not sure. The bad thing about booting from usb
is that the boot on the hd is not available until one
unplug the usb?

Don't get angry on me now. But why should I care at all
about Debian when Ubuntu using cheat iso booting
just work and allow me almost identical experience
as when I boot from Puppy. Only a bit slower due to
not using toram
I use Google Search on Puppy Forum
not an ideal solution though

jbv
Posts: 179
Joined: Sat 01 Jan 2011, 00:22

#19 Post by jbv »

Hi nooby,

If what you have said is correct about your recovery, I understand why you won't resize partitions. But, can't you rebuild the recovery? Some (I think most) recovery stuff that I've seen wont check anything. If you start it, it will wipe the partition and reload everything from scratch. Anyway, it sounds as though you know your recovery and what it wants.

The "easy way" would have been to create a small partition on the end of the disc. Drop pussy on there and let your boot-manager boot pussy from there, but then have a /live directory on your NTFS partition. It would have been sort-of like booting from a USB stick without the USB stick:)

The second "easy way" is as it seems you have now done.
Boot from the USB stick but have the /live directory on your NTFS partition /sda3.
It sounds as though that is working for you. Is it?
It should be. If not, we may be able to help sort that out somewhat easily.

You can probably make this a little easier for yourself by removing the boot manager, so that when the USB stick is installed at power-up, you will get pussy and when it is not, you will get Win7. I would have thought this would have been easier than installing the boot manager.

I guess you have to decide if you want to use pussy, puppy, Debian or Ubuntu. From what you've said it sounds as though Ubuntu will let you boot from the NTFS partition and write to it, so if you are happy with Ubuntu why bother with pussy or puppy?

If you want pussy to be bootable from the NTFS and write back to it, you may need to wait until someone has the time to pull the initrd.img image apart and look into it. It might be as simple as replacing the standard debian ntfs driver with ntfs-3g (even though that won't be quite as simple as it may have just sounded :) ).

Right now, I'm trying to sort my own issues and while I'd love to have a crack at it, I'm up to my neck in muck and fighting with my own alligators.

In your position, I'd either learn to live with the USB stick boot and just clean it up a little, or move on altogether.

emil or someone else might have some other ideas though, so don't give up just yet.

Cheers

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#20 Post by nooby »

Much appreciated you took time to help me out.
I let it be for some time. No need to hurry at all.
But if others have any suggestion I will listen.
I use Google Search on Puppy Forum
not an ideal solution though

Post Reply