7

I am playing around with the ISO image of a few Ubuntu derivatives - which should be fairly similar to Ubuntu. The version is 14.04.1 64bit. The idea here is to create a custom live USB stick, based on the live session that you get when you first boot Ubuntu from a DVD-ROM or a USB stick.

Note that, I have tried a normal installation of Ubuntu in the USB stick, but this is not suitable for me, because the USB is slow as a storage media. As a result, any session in this system was sluggish and generally ineffective.

So for best results and quicker respond the session needs to be run from a RAM-drive and the path of least effort seems to be the live Ubuntu session that you get when booting Ubuntu LiveCD or LiveUSB. If you have any other suggestion please feel free to put it forward.

I have gone through a large number of guides. I have heard of Ubuntu customization kit and of other (mostly very old) specific customizations. One thing that is certain among all guides is that the customization needs to be done in the casper initial (ram?) system. So, I have extracted the ISO image of Xubuntu, and I have unsquashed the filesystem.squashfs boot file. From what I have read the boot scripts are located in

squashfs-root/usr/share/initramfs-tools/scripts/casper-bottom/ #directory
squashfs-root/usr/share/initramfs-tools/scripts/casper #file

And what I want to achieve - at least initially - is to

  1. have my own user with my own user name.
  2. delete the live session user
  3. disable autologin

I have already tried to do this from the live session (using persistency) but lightdm autologin features are not persistent and the same is true for deleting the live session user.

so in the file casper I see there are 4 awesomely relevant entries

USERNAME=casper
USERFULLNAME="Live session user"
HOST=live
BUILD_SYSTEM=Custom

and changed it to

USERNAME=nass
USERFULLNAME="not a live session"
HOST=portableos
BUILD_SYSTEM=Custom

It looks like not only I can have my own user from boot , but also there is no need to delete the casper user as I am already the main user replacing casper :)

Unfortunately, replacing these with custom values, re-making the squashfs file system and replacing the file in the ISO does not change the live session user. The live session user is once again called "Ubuntu".

Likewise, doing chmod -x in file casper-bottom/15autologin (or even deleting it altogether) did not alter the boot process and did not ask for a password during login.

So it appears this is once again NOT the right location to create a new user, delete the casper user or to disable the autologin boot process.

So I have to ask, WHERE should I do all these customizations?

EDIT:

commenting user-session=xubuntu in squashfs-root/etc/lightdm/lightdm.conf.d/10-xubuntu.conf I have successfully disabled the autologin.

Also I have updated the file squashfs-root/etc/casper.conf

USERNAME=nass
USERFULLNAME="not a live session"
HOST=portableos
BUILD_SYSTEM=Custom

but again I boot to user "Ubuntu" - this is the only available user.

Finally, squashfs-root/etc/passwd does not contain any entry for user "Ubuntu" so I can not simply alter it there.

It goes without saying that I "mksquashfs" the file system and replace the relevant file before every attempt to boot it.

8
  • What makes you feel you improve security by doing any of this ? Post the files you modified if you need assistance. I do not believe chmod will do anything and perhaps delete the autologin file altogether would be best.
    – Panther
    Jan 30, 2015 at 16:32
  • 1
    @bodhi.zazen I tried that as well. Deleting the passwordless-ubuntu user and disabling autologin improves security, but that is not in question here. What I mostly want is a customized liveUSB. I have not modified any other other files than the ones I mention above.
    – nass
    Jan 30, 2015 at 16:37
  • 1
    to improve security why do you think doing this would improve security? It's trivial to read any files or modify the USB to remove passwords in your account.
    – Lie Ryan
    Jan 30, 2015 at 16:44
  • 1
    @LieRyan relatively speaking, if there is an autologin session one boots directly to my files and settings and history. if not, one must acquire my usb stick, plug it in another computer and access the files. Once again I seem to have to stress, 90% of the above text is about customization of a liveUSB in order to have adequately responsive session.
    – nass
    Jan 30, 2015 at 16:49
  • People are commenting on security as you mentioned it in your question. I suggest you update your question. Unless your files re encrypted the are easily accesses. You have not posted any files you have actually edited. See help.ubuntu.com/community/…
    – Panther
    Jan 30, 2015 at 17:24

4 Answers 4

6

Finally!

After endless hours of search and combining sparse information, to change the default username, one much reach into the initrd.lz. It appears that sqyashfs inherits the username as it is exported from the initial ram drive.

So once you have extracted the liveCD ISO, pick up the initrd from casper/initrd.lz , and :

  1. extract the initrd with lzma -dc -S .lz /mnt/casper/initrd.lz | cpio -id
  2. move the initrd.lz that was just extracted in the current folder, away from tcurrent folder.
  3. add your preferred username & hostname in etc/casper.conf.
  4. in the same file uncomment the "flavour" variable.

    Note that there is no need to alter the default username and values in scripts/casper. You may be confused as I was, but there is no reason why these are there. (why really?)

  5. return to the initrd root folder and recreate the initrd file as find . | cpio --quiet --dereference -o -H newc | lzma -7 > ~/new-initrd.lz

EDIT:

--dereference in step #5 above should not be used in more recent (>=17.04) versions of *ubuntu.

Now,replace the other initrd.lz under extracted-iso/casper/ and you should be able to log in with the username that you chose.

1
  • Working with the initrd.lz from Zesty Zebra 17.04, I found that there were soft links in the original initrd.lz archive, for instance linking /etc/mtab to /proc/mounts. using --dereference in then cpio when repackaging would break those. I know a lot of howtos on the web suggest --dereference, but maybe that was for older versions
    – infixed
    Jul 14, 2017 at 18:10
0
+50

Sorry for stating the obvious, but your original problem was that a live USB stick is too slow for you, so now you're trying to achieve through a software solution which is easily solved through another hardware solution...

Just buy an SLC USB stick, install Ubuntu on there, modify the boot process to your needs and you're done! 15 minutes? 20???

An SLC USB 3.0 stick is basically an SSD hard drive on a stick. They're about 2-3 times as expensive as a normal USB stick, but they're also 4-8 times as fast (for the same USB speed) and last 4-8 times as long...

The only disadvantage that I can see is that you can't expect to walk into any small shop and expect them to be on stock!

8
  • this is not a bad solution. I'm afraid that since simple things like tab completion needs to access the storage device , the whole process is by default slow. on the other had a ramdrive alleviates this problem in a very clear cut matter.
    – nass
    Feb 1, 2015 at 22:24
  • 1
    Yes! Just use a RAM disk for all tmpfs, set: vm.swappiness=10, vm.vfs_cache_pressure=75, vm.max-readahead=2048 and vm.min-readahead=1024 and you're good to go! I have such a lubuntu stick with all my most-used ISO's and utilities and use it to support Windows machines. These sticks are about 1$/GB. Just spend the 32 or 64$ and you'll never turn back! ;-)
    – Fabby
    Feb 2, 2015 at 9:02
  • 1
    where do I set these? So the overall picture is to boot to a liveCD and install ubuntu directly on the usb, then set the vm.* options (where?) and I'm good to go? how do I provide persistency? will it be included by default? perhaps by reading on these commands you suggest (are they kernel parameters?) I'll understand. If you have a guide to suggest i'd be more than welcome :)
    – nass
    Feb 2, 2015 at 10:51
  • sudo nano /etc/sysctl.conf set them at the end of the file. No need for persistency! You install from a DVD to the high-speed USB. To boot, boot from USB. Done! Chat??? AskUbuntu General room?
    – Fabby
    Feb 2, 2015 at 10:54
  • 1
    i've already upvoted.... you'll have to to look somewhere else for the downvote... which is stupid when the downvoter dows not say why....
    – nass
    Feb 5, 2015 at 15:59
0

Booting the drive, then going to User Accounts, (or Users and Groups), and adding yourself as a user, used to work, this would also get rid of user Ubuntu. The drive must have a persistent install. There may be some problem shutting down.

If you prefer the edit filesystem.squashfs method, it is probably easiest to edit this while booting from a Live DVD or a second Live USB.

If you need to edit this while booted from the target drive, then for a live USB go to filesystem/cdrom/casper/filesystem.squashfs.

If you are booting the iso file using grub2 then go to filesystem/isofile/(location of the iso) and open the iso with Archive Manager and edit the filesystem.squashfs you find there.

2
  • adding a user in an already running session does not delete the default user automagically. And the whole problem is related to what should I alter and where in the squashfs....
    – nass
    Feb 4, 2015 at 13:35
  • Hmm, I just tried adding a user, using User Accounts, on a persistent flash drive and clicking Disable Autologin. Rebooting brings up the new user name with password box. Feb 5, 2015 at 7:10
0

I confirm, it's work for me

To change user name:

  • new-initrd/etc/casper.conf

To change uid:

  • new-initrd/scripts/casper-bottom/25adduser

More about customize initrd image: https://wiki.ubuntu.com/CustomizeLiveInitrd

(Be careful to delete the file .disk/info on your usb drive because it can override your setting)

Sébastien

1
  • I found it in remaster-root/etc/casper.conf on ubuntu 16.04
    – Nazar
    Aug 8, 2017 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .