Multi-Boot RPi from Command Line [31 Oct 2013] - Raspberry Pi Development

I wrote a shell script to multi-boot my RPi from a terminal. Script can be executed remotely via SSH or VNC.
Features:
Automatically detect all ext4 partitions of all storage devices attached to RPi (ext4 is the default partition type for hosting an RPi-compatible OS)
Reconstruct boot device names (root=/dev/*) from partition editor output. No changes are made to storage devices
Generate table of boot options and prompt user for option
Include option to shutdown
Reboot to selected rootfs, e.g. /dev/sda2 according to user-selected boot option
Script uses partition editor (parted) to identify the storage device paths. I did have to install parted on Raspbmc:
Code:
sudo apt-get install parted
Presently I have triple boot:
Raspbian #1 on SD (/dev/mmcblk0p2)
Raspbian #2 on USB HD (/dev/sda2)
Raspbmc on USB HD (/dev/sda4)
Partition Info:
PNY 16GB SD
[email protected]:/boot# parted /dev/mmcblk0 print
Model: SD SD16G (sd/mmc)
Disk /dev/mmcblk0: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 4194kB 62.9MB 58.7MB primary fat16 lba
2 62.9MB 16.0GB 15.9GB primary ext4
Western Digital 160GB HD 7200 RPM
[email protected]:/boot# parted /dev/sda print
Model: WDC WD1600BJKT-75F4T (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 4194kB 62.9MB 58.7MB primary fat16 lba
2 77.6MB 21.5GB 21.5GB primary ext4
3 21.5GB 25.8GB 4295MB primary linux-swap(v1)
4 25.8GB 160GB 134GB primary ext4
And here's the boot script (/boot/rpiboot.sh):
Code:
#!/bin/sh
echo
echo "Reboot RPi to rootfs... "
cd /boot
ftxt="cmdline.txt"
fbak="cmdline.bak"
fnew="cmdline.new"
if [ -f $fnew ]
then
rm $fnew
fi
echo
rootfs=$(awk '{for (i=1; i<NF; i++) if (match($i,"root=")) {sub("root=", "", $i); print $i} }' $ftxt)
echo "Current rootfs: $rootfs"
#Reconstructing device names from partition editor output
parted /dev/mmcblk0 print > parted.txt
mmcname=$(awk '/\/dev\// {printf "%s", substr($2,1,length($2)-1) }' parted.txt)
awk -v mmcname=$mmcname '/ext4/ {printf "%sp%d\n", mmcname, $1 > "ext4.txt" }' parted.txt
parted /dev/sda print > parted.txt
mmcname=$(awk '/\/dev\// {printf "%s", substr($2,1,length($2)-1) }' parted.txt)
awk -v mmcname=$mmcname '/ext4/ {printf "%s%d\n", mmcname, $1 >> "ext4.txt" }' parted.txt
echo
echo "Boot options for rootfs:"
cat -n ext4.txt > ext4_enum.txt
more ext4_enum.txt
echo
printf "Enter boot option (press ENTER to shutdown or CNTL-z to exit):"
read -r ext4_index
if test -z "$ext4_index"
then
echo
echo "Shutting down in 3 seconds..."
sleep 3
shutdown -h now
exit 0
fi
#Determine rootfs corresponding to boot option
rootfs=$(awk -v ext4_index=$ext4_index '{if (match($1,ext4_index)) print $2}' ext4_enum.txt)
if test -z "$rootfs"
then
echo
echo "Invalid boot option or other error. Exiting..."
exit 1
fi
awk -v rootfs=$rootfs -v fnew=$fnew '{
for (i=1; i<NF; i++) if (match($i,"root=")) {$i = "root=" rootfs; print $0 > fnew} }' $ftxt
if [ -f $fnew ]
then
printf "Press ENTER to reboot to $rootfs, or CNTL-z to exit."
read -r text
mv $ftxt $fbak
mv $fnew $ftxt
fi
echo
echo "/boot/cmdline.txt:"
more $ftxt
echo "Rebooting to $rootfs in 3 seconds..."
sleep 3
reboot
exit 0
Launching rpiboot.sh as root, here are my own results of a boot switch from /dev/sda2 (Raspbian) to /dev/sda4 (Raspbmc):
Code:
[email protected] ~ $ sudo sh /boot/rpiboot.sh
Reboot RPi to rootfs...
Current rootfs: /dev/sda2
Boot options for rootfs:
1 /dev/mmcblk0p2
2 /dev/sda2
3 /dev/sda4
Enter boot option (press ENTER to shutdown or CNTL-z to exit):3
Press ENTER to reboot to /dev/sda4, or CNTL-z to exit.
/boot/cmdline.txt:
dwc_otg.lpm_enable=0 root=/dev/sda4 rootfstype=ext4 noatime quiet rootwait loglevel=1 sdhci-bcm2708.enable_l
lm=1 dwc_otg.microframe_schedule=1 dwc_otg.fiq_fix_enable=0 dwc_otg.fiq_split_enable=0 dwc_otg.trans_backoff
=3000
Rebooting to /dev/sda4 in 3 seconds...
Broadcast message from [email protected] (pts/0) (Thu Oct 31 15:28:20 2013):
The system is going down for reboot NOW!
[email protected] ~ $ Connection to 10.0.0.16 closed by remote host.
Connection to 10.0.0.16 closed.
[email protected]:~#
And voila, Raspbmc comes up. I now SSH in from my Ubuntu laptop:
Code:
[email protected]:~# ssh [email protected]
[email protected]'s password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
[email protected]:~$
Of course VNC renders the elegant desktop experience, and setting up VNC is fairly straightforward:
http://learn.adafruit.com/adafruit-...control-with-vnc/running-vncserver-at-startup
However VNC does not work on Raspbmc since VNC relies on the X11 window system, while Raspbmc’s XBMC implementation is rendered in the framebuffer only. Thus VNC cannot be used as there is no X-session available for connection. See:
http://www.raspbmc.com/wiki/user/frequently-asked-questions/
But SSH works well.
Blessings. Enjoy!

tanks!
hello is verry good
please tuto create multiboot for noobs lol

And Raspbmc is EOL.

help
[email protected]:~ $ df -h
Sys. de fichiers Taille Utilis▒ Dispo Uti% Mont▒ sur
/dev/root 7,2G 4,5G 2,5G 65% /
devtmpfs 364M 0 364M 0% /dev
tmpfs 368M 0 368M 0% /dev/shm
tmpfs 368M 5,3M 363M 2% /run
tmpfs 5,0M 4,0K 5,0M 1% /run/lock
tmpfs 368M 0 368M 0% /sys/fs/cgroup
tmpfs 1,0M 4,0K 1020K 1% /var/pipeyelog
/dev/mmcblk0p1 60M 20M 41M 34% /boot
tmpfs 74M 0 74M 0% /run/user/1000
/dev/sda3 6,3G 15M 6,0G 1% /media/pi/e836e8e0-22be-4f6e-8836-1f4 039a627e8
/dev/sda2 7,2G 4,5G 2,5G 65% /media/pi/ad6203a1-ec50-4f44-a1c0-e6c 3dd4c9202
/dev/sda1 60M 20M 41M 34% /media/pi/boot
[email protected]:~ $ sudo sh /boot/rpiboot.sh
Reboot RPi to rootfs...
Current rootfs: /dev/mmcblk0p2
Boot options for rootfs:
1 /dev/mmcblk0p2
Enter boot option (press ENTER to shutdown or CNTL-z to exit):^Z
[1]+ Stopp▒ sudo sh /boot/rpiboot.sh
[email protected]:~ $
why not see my sda2 and sda3 partition ( Raspbian and raspbmc ) ??

Related

[Q] Debian AlternativeOS fails in Uruk 1.5

I plug my Archos 101 into my laptop and copy an unarchived Debian rootfs image to rootfs.img, unmount, unplug and reboot. In the alternative OS menu, I choose Debian and stock Android boots. When I mount the image, it looks fine.
Is AlterntativeOS working in 1.5? If so, where might I be going wrong?
pengyo said:
I plug my Archos 101 into my laptop and copy an unarchived Debian rootfs image to rootfs.img, unmount, unplug and reboot. In the alternative OS menu, I choose Debian and stock Android boots. When I mount the image, it looks fine.
Is AlterntativeOS working in 1.5? If so, where might I be going wrong?
Click to expand...
Click to collapse
Here is howto for Debian in AlternativeOS - i'll prepare Video later.
http://code.google.com/p/urukdroid/wiki/RM_AlternativeOS_Debian
Thank you!
I used your updated script with the name deb.boot.
It came up in the boot screen, but the behavior was the same.
No log output was generated in the AlternativeOS directory.
I also tried creating /mnt/card, which did not exist, and
changing the device name to /dev/block/vold/179:9 which is
what 'mount' reports for the partition mounted on /mnt/storage that
contains the image.
Here is (crappy I know - sorry ) video how bootup looks like
The video helps, thank you. When I take the same steps, my
system passes through the 'booting' screen much faster and
goes to Android.
Here is something from dmesg that may be related:
Code:
EXT4-fs: mmcblk2p1: Filesystem with huge files cannot be mounted read-write without CONFIG_LBD.
I am running Urukdroid 1.5 upgraded in the default ways from 1.0 that
was installed without incident using simple install. My SD card is a 16G PNY type 4 card,
which has been dreadfully slow and on which iobench hangs at 52%. This also
causes many aplications to trigger the 'kill or wait' dialogue (the applications
generally respond if I wait).
EDIT:
I flashed the 1.5 kernel and initramfs.
I tried the following from the post on booting Urukdroid from openAOS BootMenu:
"you may have to disable huge_file on your ext4 partition/file using tune2fs -O ^huge_file yourfile.img or /dev/yourpartition"
and I tried preceeding my device name with
/dev , /dev/block, and /dev/block/vold
Still no success, and no log output.
pengyo said:
The video helps, thank you. When I take the same steps, my
system passes through the 'booting' screen much faster and
goes to Android.
Here is something from dmesg that may be related:
Code:
EXT4-fs: mmcblk2p1: Filesystem with huge files cannot be mounted read-write without CONFIG_LBD.
Click to expand...
Click to collapse
Probably you have formatted this partition manually - with huge_files options, do it again without it.
Debian AlterntiveOS fails in Uruk 1.5
Hello at all,
my Archos device is a Archos 70 IT with 250GB hard drive, without SD card.
Have according to instructions from $aur0n repartitioned the hdd, extra partition created for the image files.
According to fdisk it is /dev/sda4, but I can not mount.
mount /dev/sda4 /mnt/card
(mount: special device /dev/sda4 does not exist)
When I mount the device with mount /dev/block/sda4 /mnt/card, I can access it.
ls -l says:
-rwxrwxrwx 1 1000 1015 4026531840 Jul 26 09:48 rootfs.img
the debian.boot is this:
*************************************************************************************************************
#!/bin/sh
#
# Script to boot alternative OS: Debian
#
# OS_Name: Debian
# OS_Desc: Debian armel
#
# Ver: 1.2 (17.08.2011) Adrian (Sauron) Siemieniak
#
set -xv
# Device where debian image reside (storagefs on sdcard in example)
debian_dev="/dev/block/sda4"
debian_dev_mountp="/mnt/card"
# Debian image file
debian_img="rootfs.img"
debian_mountp="/AlternativeOS"
# Mounting device where image file reside
$MOUNT $debian_dev $debian_dev_mountp || log "Failed to mount device with debian file"
# Creating loop device
$LOSETUP /dev/loop0 $debian_dev_mountp"/"$debian_img || log "Mounting system partition failed"
# Mounting debian rootfs disk
$MOUNT /dev/loop0 $debian_mountp
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
# IF it fails - we can do some clean ups
$UMOUNT $debian_mountp
$UMOUNT $debian_dev_mountp
*************************************************************************************************************
The Folder, /mnt/card, have i created manually.
When boot to AlternativeOS - debian, debian does not start.
Android Froyo starts.
When i reboot to Developer Edition, UrukDroid starts normaly.
When i boot the Image under Standard Froyo as Developer Edition it's OK.
What is wrong?
Can anyone help me?
Sorry for my bad english.
best regards
kwalter
Check /AlternativeOS/debug.txt. It's certainly not /dev/block/xxx (this path is correct AFTER Uruk is booted, during initramfs its /dev/)
debug.txt is empty.
i have changed to: debian_dev="/dev/sda4"
The problem is the same.
kwalter said:
debug.txt is empty.
Click to expand...
Click to collapse
Make sure /AlternativeOS/debian.boot has +x for user (chmod u+x /AlternativeOS/debian.boot).
i have done chmod u+x /AlternativeOS/debian.boot
The Problem is the same.
k - i join in
tried the same with openAOS
used the script from http://code.google.com/p/urukdroid/wiki/RM_AlternativeOS_Debian (copy & paste) all I edited was rootfs.img -> openAOS.img
mkdir /mnt/card
rm /AlternativeOS/debug.txt
chmod 777 /AlternativeOS/openAOS.boot
openAOS.img is in root for SDCard -> mnt/storage/sdcard/openAOS.img
tried to boot (rescure menu -> select openAOS) -> short white bootup dialog of AlternativeOS (openAOS) -> blackscreen -> reboot (will boot stock FW) -> no debug.txt created
tried again with creating debug.txt again (with vi empty file :wq)
chmod 666 debug.txt
-> same as above nothing in debug.txt
FrEcP said:
k - i join in
mkdir /mnt/card
Click to expand...
Click to collapse
This is not required - since it's /mnt/card on initramfs (and there is this directory).
About debug.txt - I'll add more debug information and put new package.
edit: Your problem (lack of debug.txt) is because device reboot itself before it finish writing to disk... So either give "sync" after every command - or remove for a while "switch" - which cause device to reboot.
Anyway I'll modified initramfs and script to be more user friendly - I'll publish it soon...
@$auron
..... I would like to try debian ... but I don't understand at all the instructions to do it can you do a tread about this ... or maybe instructions on wiki ???
Ok,
So install this UD package
http://sauron.pourix.com/UrukDroid/UrukDroid-1.5/UrukDroid-1.5.1-kernel.tbz2
Use this boot script
Code:
#!/bin/sh
#
# Script to boot alternative OS: Debian
#
# OS_Name: Debian
# OS_Desc: Debian armel
#
# Ver: 1.2 (17.08.2011) Adrian (Sauron) Siemieniak
#
set -xv
# Device where debian image reside (storagefs on sdcard in example)
debian_dev="/dev/mmcblk2p1"
debian_dev_mountp="/mnt/card"
# Debian image file
debian_img="rootfs.img"
debian_mountp="/AlternativeOS"
# Mounting device where image file reside
$MOUNT $debian_dev $debian_dev_mountp || log_msg "Failed to mount device with debian file"
sync
# Creating loop device
$LOSETUP /dev/loop0 $debian_dev_mountp"/"$debian_img || log_msg "Mounting AlternativeOS partition failed"
sync
# Mounting debian rootfs disk
$MOUNT /dev/loop0 $debian_mountp
# It mount went ok
if [ $! -eq 0 ]; then
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
fi
# IF it fails - we can do some clean ups
$UMOUNT $debian_mountp
$UMOUNT $debian_dev_mountp
This is how debug.txt will look like (this bootup failed because rootfs.img is missing)
Code:
Fri Aug 19 07:48:21 MDT 2011
Booting up Alternative OS: debian
Bootup file is: /new-root/AlternativeOS/debian.boot
# Device where debian image reside (storagefs on sdcard in example)
debian_dev="/dev/mmcblk2p1"
+ debian_dev=/dev/mmcblk2p1
debian_dev_mountp="/mnt/card"
+ debian_dev_mountp=/mnt/card
# Debian image file
debian_img="rootfs.img"
+ debian_img=rootfs.img
debian_mountp="/AlternativeOS"
+ debian_mountp=/AlternativeOS
# Mounting device where image file reside
$MOUNT $debian_dev $debian_dev_mountp || log_msg "Failed to mount device with debian file"
+ /bin/mount /dev/mmcblk2p1 /mnt/card
sync
+ sync
# Creating loop device
$LOSETUP /dev/loop0 $debian_dev_mountp"/"$debian_img || log_msg "Mounting AlternativeOS partition failed"
+ /sbin/losetup /dev/loop0 /mnt/card/rootfs.img
losetup: /dev/loop0: No such file or directory
+ log_msg Mounting AlternativeOS partition failed
+ /bin/aui -c message -t AlternativeOS: Mounting AlternativeOS partition failed
sync
+ sync
# Mounting debian rootfs disk
$MOUNT /dev/loop0 $debian_mountp
+ /bin/mount /dev/loop0 /AlternativeOS
mount: mounting /dev/loop0 on /AlternativeOS failed: Invalid argument
# It mount went ok
if [ $! -eq 0 ]; then
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
fi
+ [ 575 -eq 0 ]
# IF it fails - we can do some clean ups
$UMOUNT $debian_mountp
+ /bin/umount /AlternativeOS
umount: can't umount /AlternativeOS: Invalid argument
$UMOUNT $debian_dev_mountp
+ /bin/umount /mnt/card
rplc790222 said:
@$auron
..... I would like to try debian ... but I don't understand at all the instructions to do it can you do a tread about this ... or maybe instructions on wiki ???
Click to expand...
Click to collapse
There IS instruction of wiki.
$aur0n said:
Ok,
So install this UD package
http://sauron.pourix.com/UrukDroid/UrukDroid-1.5/UrukDroid-1.5.1-kernel.tbz2
Use this boot script
Code:
#!/bin/sh
#
# Script to boot alternative OS: Debian
#
# OS_Name: Debian
# OS_Desc: Debian armel
#
# Ver: 1.2 (17.08.2011) Adrian (Sauron) Siemieniak
#
set -xv
# Device where debian image reside (storagefs on sdcard in example)
debian_dev="/dev/mmcblk2p1"
debian_dev_mountp="/mnt/card"
# Debian image file
debian_img="rootfs.img"
debian_mountp="/AlternativeOS"
# Mounting device where image file reside
$MOUNT $debian_dev $debian_dev_mountp || log_msg "Failed to mount device with debian file"
sync
# Creating loop device
$LOSETUP /dev/loop0 $debian_dev_mountp"/"$debian_img || log_msg "Mounting AlternativeOS partition failed"
sync
# Mounting debian rootfs disk
$MOUNT /dev/loop0 $debian_mountp
# It mount went ok
if [ $! -eq 0 ]; then
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
fi
# IF it fails - we can do some clean ups
$UMOUNT $debian_mountp
$UMOUNT $debian_dev_mountp
This is how debug.txt will look like (this bootup failed because rootfs.img is missing)
Code:
Fri Aug 19 07:48:21 MDT 2011
Booting up Alternative OS: debian
Bootup file is: /new-root/AlternativeOS/debian.boot
# Device where debian image reside (storagefs on sdcard in example)
debian_dev="/dev/mmcblk2p1"
+ debian_dev=/dev/mmcblk2p1
debian_dev_mountp="/mnt/card"
+ debian_dev_mountp=/mnt/card
# Debian image file
debian_img="rootfs.img"
+ debian_img=rootfs.img
debian_mountp="/AlternativeOS"
+ debian_mountp=/AlternativeOS
# Mounting device where image file reside
$MOUNT $debian_dev $debian_dev_mountp || log_msg "Failed to mount device with debian file"
+ /bin/mount /dev/mmcblk2p1 /mnt/card
sync
+ sync
# Creating loop device
$LOSETUP /dev/loop0 $debian_dev_mountp"/"$debian_img || log_msg "Mounting AlternativeOS partition failed"
+ /sbin/losetup /dev/loop0 /mnt/card/rootfs.img
losetup: /dev/loop0: No such file or directory
+ log_msg Mounting AlternativeOS partition failed
+ /bin/aui -c message -t AlternativeOS: Mounting AlternativeOS partition failed
sync
+ sync
# Mounting debian rootfs disk
$MOUNT /dev/loop0 $debian_mountp
+ /bin/mount /dev/loop0 /AlternativeOS
mount: mounting /dev/loop0 on /AlternativeOS failed: Invalid argument
# It mount went ok
if [ $! -eq 0 ]; then
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
fi
+ [ 575 -eq 0 ]
# IF it fails - we can do some clean ups
$UMOUNT $debian_mountp
+ /bin/umount /AlternativeOS
umount: can't umount /AlternativeOS: Invalid argument
$UMOUNT $debian_dev_mountp
+ /bin/umount /mnt/card
There IS instruction of wiki.
Click to expand...
Click to collapse
Jajajaja I missed the wiki instructions, my bad ... I will try later
I re-formatted my microsd card, with huge_file option disabled on the first partition.
The debug output shows the script runs, echoing each command without errors until
#IF mount went ok
after that block, the output differs from yours slightly:
+[ 563 -eq 0]
Then the umount commands close with another line of different output:
+/bin/umount /mnt/card
umount: can't umount /mnt/card: Device or resource busy
The output in the alternative boot menu is something to the effect
'debian failed to boot' and goes back to boot options.
pengyo said:
I re-formatted my microsd card, with huge_file option disabled on the first partition.
The debug output shows the script runs, echoing each command without errors until
#IF mount went ok
after that block, the output differs from yours slightly:
+[ 563 -eq 0]
Then the umount commands close with another line of different output:
+/bin/umount /mnt/card
umount: can't umount /mnt/card: Device or resource busy
The output in the alternative boot menu is something to the effect
'debian failed to boot' and goes back to boot options.
Click to expand...
Click to collapse
same here - full debug.txt:
Fri Aug 19 17:55:21 MDT 2011
Booting up Alternative OS: openAOS
Bootup file is: /new-root/AlternativeOS/openAOS.boot
# Device where debian image reside (storagefs on sdcard in example)
debian_dev="/dev/mmcblk2p1"
+ debian_dev=/dev/mmcblk2p1
debian_dev_mountp="/mnt/card"
+ debian_dev_mountp=/mnt/card
# Debian image file
debian_img="openAOS.img"
+ debian_img=openAOS.img
debian_mountp="/AlternativeOS"
+ debian_mountp=/AlternativeOS
# Mounting device where image file reside
$MOUNT $debian_dev $debian_dev_mountp || log_msg "Failed to mount device with debian file"
+ /bin/mount /dev/mmcblk2p1 /mnt/card
sync
+ sync
# Creating loop device
$LOSETUP /dev/loop0 $debian_dev_mountp"/"$debian_img || log_msg "Mounting AlternativeOS partition failed"
+ /sbin/losetup /dev/loop0 /mnt/card/openAOS.img
sync
+ sync
# Mounting debian rootfs disk
$MOUNT /dev/loop0 $debian_mountp
+ /bin/mount /dev/loop0 /AlternativeOS
# It mount went ok
if [ $! -eq 0 ]; then
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
fi
+ [ 563 -eq 0 ]
# IF it fails - we can do some clean ups
$UMOUNT $debian_mountp
+ /bin/umount /AlternativeOS
$UMOUNT $debian_dev_mountp
+ /bin/umount /mnt/card
umount: can't umount /mnt/card: Device or resource busy
Thanks for showing us how to get output into the log file $auron.
It seems the problem is at the switch_root command. It gives a usage
message as if it did not recognize one of its arguments- the mount point
or the init.
FrEcP said:
same here - full debug.txt:
$MOUNT /dev/loop0 $debian_mountp
+ /bin/mount /dev/loop0 /AlternativeOS
# It mount went ok
if [ $! -eq 0 ]; then
# Switching to debian
exec /sbin/switch_root $debian_mountp /sbin/init
fi
+ [ 563 -eq 0 ]
Click to expand...
Click to collapse
This is the problem (not switch root). Mount failed. Mount returned 563 output - and should 0. That's why switch_root is even not executed.

making a nook-bootable SD card (in general) on Linux

It took me a while to figure out why verygreen's image worked, but I was not able to reproduce the result by creating my own partitions and copying his files over. Looking more closely at verygreen's image and my own, I noticed that the first partitions started at different positions. I was able to get my homebrew SD card working just by making the first partition start at the 63rd sector:
Code:
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 15.9 GB, 15931539456 bytes
64 heads, 32 sectors/track, 15193 cylinders, total 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e525a
Device Boot Start End Blocks Id System
/dev/sdb1 * 63 329790 164864 e W95 FAT16 (LBA)
/dev/sdb2 329791 1312830 491520 83 Linux
/dev/sdb3 1312831 3409982 1048576 83 Linux
/dev/sdb4 3409983 31116287 13853152+ c W95 FAT32 (LBA)
How do you do this using fdisk? After you create the first partition, type 'x' for extra functionality (experts only). From there, you could then type 'b', then '1', then '63' to make your first partition start at the right place. Press 'r' to return to the main menu, and make the rest of your partitions from there. Note that this operation breaks whatever filesystem was originally on the first partition, so it would need to be reformatted. MAKE BACKUPS. Don't forget to write changes!
FatTire and nemith confirmed that the first partition needed to be special, and pointed to this informational page. It even contains a nifty script. I didn't need most of that, since tweaking the beginning-of-data worked for me every time, but give it a read anyway.
You know, I'm sure this was something very simple for the ones that knew. But I too struggled with creating a bootable sdcard from scratch. I would set up all the correct partitions with the correct flags and still nogo. Who would've thought it would be something as simple as that. Thanks for this!
-Racks
Now I can create my own "Verygreen" installer img, muah ha hah... It was that whole formatting the uSD thing with those special considerations that has been tripping me up the whole time.
This didnt work for me, anyone have a script that could format a boot partition and an ext 3 partition with it? one with custom boot size like 4Gb fat or 3GB fat or 5GB fat prefferably 4.5GB but if you know how to customise the script below to create 4.5 GB fat partiton right now this creates only a 73 Mb fat partition the rest ext3
#! /bin/sh
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory <[email protected]>
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
export LC_ALL=C
if [ $# -ne 1 ]; then
echo "Usage: $0 <drive>"
exit 1;
fi
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
sleep 1
if [ -x `which kpartx` ]; then
kpartx -a ${DRIVE}
fi
# handle various device names.
# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1
# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572
PARTITION1=${DRIVE}1
if [ ! -b ${PARTITION1} ]; then
PARTITION1=${DRIVE}p1
fi
DRIVE_NAME=`basename $DRIVE`
DEV_DIR=`dirname $DRIVE`
if [ ! -b ${PARTITION1} ]; then
PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1
fi
PARTITION2=${DRIVE}2
if [ ! -b ${PARTITION2} ]; then
PARTITION2=${DRIVE}p2
fi
if [ ! -b ${PARTITION2} ]; then
PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2
fi
# now make partitions.
if [ -b ${PARTITION1} ]; then
umount ${PARTITION1}
mkfs.vfat -F 32 -n "boot" ${PARTITION1}
else
echo "Cant find boot partition in /dev"
fi
if [ -b ${PARITION2} ]; then
umount ${PARTITION2}
mke2fs -j -L "Angstrom" ${PARTITION2}
else
echo "Cant find rootfs partition in /dev"
fi
DroidisLINUX said:
This didnt work for me, anyone have a script that could format a boot partition and an ext 3 partition with it? one with custom boot size like 4Gb fat or 3GB fat or 5GB fat prefferably 4.5GB but if you know how to customise the script below to create 4.5 GB fat partiton right now this creates only a 73 Mb fat partition the rest ext3
#! /bin/sh
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory <[email protected]>
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
export LC_ALL=C
if [ $# -ne 1 ]; then
echo "Usage: $0 <drive>"
exit 1;
fi
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
sleep 1
if [ -x `which kpartx` ]; then
kpartx -a ${DRIVE}
fi
# handle various device names.
# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1
# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572
PARTITION1=${DRIVE}1
if [ ! -b ${PARTITION1} ]; then
PARTITION1=${DRIVE}p1
fi
DRIVE_NAME=`basename $DRIVE`
DEV_DIR=`dirname $DRIVE`
if [ ! -b ${PARTITION1} ]; then
PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1
fi
PARTITION2=${DRIVE}2
if [ ! -b ${PARTITION2} ]; then
PARTITION2=${DRIVE}p2
fi
if [ ! -b ${PARTITION2} ]; then
PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2
fi
# now make partitions.
if [ -b ${PARTITION1} ]; then
umount ${PARTITION1}
mkfs.vfat -F 32 -n "boot" ${PARTITION1}
else
echo "Cant find boot partition in /dev"
fi
if [ -b ${PARITION2} ]; then
umount ${PARTITION2}
mke2fs -j -L "Angstrom" ${PARTITION2}
else
echo "Cant find rootfs partition in /dev"
fi
Click to expand...
Click to collapse
Code:
# fdisk /dev/sdb
Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Print card info:
Command (m for help): p
Disk /dev/sdb: 128 MB, 128450560 bytes
....
Note card size in bytes. Needed later below.
Then go into "Expert mode":
Command (m for help): x
Now we want to set the geometry to 255 heads, 63 sectors and calculate the number of cylinders required for the particular SD/MMC card:
Expert command (m for help): h
Number of heads (1-256, default 4): 255
Expert command (m for help): s
Number of sectors (1-63, default 62): 63
Warning: setting sector offset for DOS compatiblity
Expert command (m for help): c
Number of cylinders (1-1048576, default 1011): 15
In this case 128MB card is used (reported as 128450560 bytes by fdisk above), thus 128450560 / 255 / 63 / 512 = 15.6 rounded down to 15 cylinders. Numbers there are 255 heads, 63 sectors, 512 bytes per sector.
Now, return to main mode and create a new partition:
Expert command (m for help): r
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-15, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-15, default 15): 15
Mark it bootable:
Command (m for help): a
Partition number (1-4): 1
And change its type to FAT32:
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))
The result is:
Command (m for help): p
Disk /dev/sdb: 128 MB, 128450560 bytes
255 heads, 63 sectors/track, 15 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 15 120456 c W95 FAT32 (LBA)
Now, really write configuration to card (until here, card is not changed):
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
Done! What's left is to format our partition as FAT32 to be mounted and populated:
# mkfs.vfat -F 32 /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)
Note: before running mkfs.vfat (included in the dosfstools package in Debian) make sure /dev/sdb is not mounted.
# mount /dev/sdb1 /mnt/tmp
Note: If you use additional mkfs.vfat parameter -n you can give the card a name, e.g. for easier identification (i.e. mkfs.vfat -n omap3 -F 32 /dev/sdb1)
The SD/MMC card is now ready to be used to boot OMAP3 boards.
sfdisk
In order to format same card using sfdisk, one needs to do the following:
# sfdisk -H 255 -S 63 -C 15 /dev/sdb << EOF
> ,,b,*
> EOF
This worked for me, once I used mkcard.sh I deleted the partitions then created a new partition following these steps and now I have a 4.5 Gb boot partition and a 3.0 ext3 Angstrom partition and a 500 Mb swap partition I found that the angstrom only needed about 2.7 to 2.8 Gb or space so that was why I wanted it this way so I could still have a large sdcard when I boot normaly.
I did have to do some math as my sdcard is a 8 GB sdcard not a 128 megs but once i did the math the cyclenders came out to be 966 and then I did everything else like it said make sure to add bootable flag and edit first sector at 63 on the first partition then it works, if you have problems try to change id to option e worked (W95 FAT16 (LBA)) and use mkfs.vfat -F 16 /dev/sdb1 other wise try option c mkfs.vfat -F 32 /dev/sdb1. I got the fat 32 to work so I am happy

[HOWTO] fix your partitions on your nook tablet 16GB (UNBRICK)

Hello!
The partitions on my nook got messy, and when i tried to use the repart.img i got a red X.
i found this guide by so****e whice didn't work for me, but defenetly helped me and everything that is written here is based on it.
Download the files from so****e thread and put them where it says. When you get to the part of the commands- come back here. (in the last link, one file (scrips) is down from the server. you can get this file here.)
This should work for the nook tablet 16GB, i don't know about the 8GB.
This method worked for me, i'm not sure it will work for you, but it should.
I am not responsible for any damage; anyhow this should fix the damage. DO NOT try this if you don't have any experience. Before you do enything, read everything and make sure you understand.
After you have all the files in the right place, and you are in CWM recovery, let's get started.
In CWM, get into mounts and storage, and then get into mount SDcard.
Open the CMD in your computer, connect your nook to your computer and let's start the work
After you write "adb devices", make sure you see the serial number and recovery:
Code:
$ adb start-server
$ adb devices
This will backup your rom partition, which holds important information, like serial no. and MAC address- When i tried to save it i got an error, maybe this will work for you, this is pretty important:
Code:
$ adb shell
~ # mount sdcard
~ # dd if=/dev/block/mmcblk0p5 of=/sdcard/blk/mmcblk0p5
Then:
Code:
~ # cd sdcard
/sdcard # ./sgdisk -Z /dev/block/mmcblk0
/sdcard # ./sgdisk /dev/block/mmcblk0 -a 256 -n 1:256:511 -n 0:0:1023 -n 0:0:31743 -n 0:0:65535 -n 0:0:163839 -n 0:0:262143 -n 0:0:1019903 -n 0:0:2273279 -n 0:0:3145727 -n 0:0:+12G -n 0:0:0
/sdcard # ./sgdisk -c 1:xloader -c 2:bootloader -c 3:recovery -c 4:boot -c 5:rom -c 6:bootdata -c 7:factory -c 8:system -c 9:cache -c 10:media -c 11:userdata /dev/block/mmcblk0
/sdcard # ./sgdisk -p /dev/block/mmcblk0
Then:
Code:
/sdcard # cd /sdcard/sbin
/sdcard # ./genptable /tmp/genptable
Then:
Code:
/sdcard # mv /tmp/genptable /sdcard/blk
~ # dd if=/sdcard/blk/genptable of=/dev/block/mmcblk0
Then:
Code:
/sdcard # cd sbin
/sdcard/sbin # ./mkdosfs -F 32 /dev/block/mmcblk0p5
/sdcard/sbin # ./mkdosfs -F 32 /dev/block/mmcblk0p6
/sdcard/sbin # ./mkdosfs -F 32 /dev/block/mmcblk0p10
Then:
Code:
/sdcard/sbin # cd ../../
~ # dd if=/sdcard/blk/mmcblk0p1 of=/dev/block/mmcblk0p1
~ # dd if=/sdcard/blk/mmcblk0p2 of=/dev/block/mmcblk0p2
~ # dd if=/sdcard/blk/mmcblk0p3 of=/dev/block/mmcblk0p3
~ # dd if=/sdcard/blk/mmcblk0p4 of=/dev/block/mmcblk0p4
~ # dd if=/sdcard/blk/mmcblk0p5 of=/dev/block/mmcblk0p5
Then:
Code:
~ # parted /dev/block/mmcblk0
(parted) mkpartfs primary ext2 134MB 522MB
(parted) mkpartfs primary ext2 522MB 1164MB
(parted) mkpartfs primary ext2 1164MB 1611MB
(parted) mkpartfs primary ext2 2684MB 15.9GB
Then:
Code:
(parted) quit
~ # tune2fs -j /dev/block/mmcblk0p7
~ # e2fsck -fDp /dev/block/mmcblk0p7
~ # tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p7
~ # e2fsck -fDp /dev/block/mmcblk0p7
~
~ # tune2fs -j /dev/block/mmcblk0p11
~ # e2fsck -fDp /dev/block/mmcblk0p11
~ # tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p11
~ # e2fsck -fDp /dev/block/mmcblk0p11
Then:
Code:
~ # parted /dev/block/mmcblk0
(parted) name 1 xloader
(parted) name 2 bootloader
(parted) name 3 recovery
(parted) name 4 boot
(parted) name 5 rom
(parted) name 6 bootdata
(parted) name 7 factory
(parted) name 8 system
(parted) name 9 cache
(parted) name 10 media
(parted) name 11 userdata
To make sure that everything is OK, do this:
Code:
(parted) print
If you did everything right, you should get something like this:
Code:
Number Start End Size File system Name Flags
1 131kB 262kB 131kB xloader
2 262kB 524kB 262kB bootloader
3 524kB 16.3MB 15.7MB recovery
4 16.3MB 33.6MB 17.3MB boot
5 33.6MB 83.9MB 50.3MB fat32 rom
6 83.9MB 134MB 50.3MB fat32 bootdata
7 134MB 522MB 388MB ext4 factory
8 522MB 1164MB 642MB system
9 1164MB 1611MB 447MB cache
10 1611MB 14.5GB 12.9GB fat32 media
11 14.5GB 15.9GB 1430MB ext4 userdata
###As you can see the "File system" in 8&9 are missing. After a rom installtion it will fix itself###
From here, just go to CWM, install your favorite rom and you are good to go.
[notice]If you have bootloader problem like me, just download "CyanoBoot" (Universal Bootloader).
Sorry if I had any spelling mistake,
and Goodluck!

Resize Partitions

Hello,
my phone is an E2303. The only problem for me with this phone is the limited memory.
I have rooted the phone the way explained in http://forum.xda-developers.com/m4-a.../root-t3421932
With Root Explorer, i removed a lot of stuff in /system. Now 1,66 GB are used and 810 MB are free.
usderdata and system partitions ( sgdisk --print /dev/block/mmcblk0 )
Nr Name Start Stop Size type
29 userdata 1449984 10043391 4.1 GIB 8300
30 system 10043392 15269375 2.5 GIB 8300
My idea:
- use TWRP to backup userdata and system partions
- delete both partitions
- create userdata with 4.6 GIB
- create system with 2 GIB
- format both partitions with make_extfs4
- restore both partitions with TWRP
I know that as a consequence, i'm not able to flash updates.
Do you think, that this would work ?
===[ Update 5.12.2016 ]===
Yes !
I've attatched my scripts to this initial post. Howto follows ...
i can tell you that something similar worked on lg g2 mini (d610/d618)
that phone have a cache partition with 1gb of unused storage, so a developer resized to reduce this to 100mb, you can find this on L90 or g2 mini forum
did you try it yet?
try and give info
resize partitions Script
Hello,
i've startet coding a shell script:
------------------------------------------------------------
#!/bin/bash
MMC=/dev/block/mmcblk0
NEW_FREE_SEC=65536 # 32 mbyte in sectors
if [ $(id -u) -ne 0 ]; then
echo "Only root is allowed"
exit
fi
mount | grep "$MMC" > /dev/null
RC=$?
if [ $RC -eq 1 ]; then
echo "system not mounted. mounting now"
mount /system
RC=$?
echo $RC
fi
FREE_MB=$(df -P -m /system/ | grep 'mmcblk0p30' | awk '{print $4}')
FREE_KB=$(df -Pk /system/ | grep 'mmcblk0p30' | awk '{print $4}')
FREE_SEC=$(df -P -B 512 /system/ | grep 'mmcblk0p30' | awk '{print $4}')
echo "Your system partion has $FREE_MB mbyte free ( kbyte = $FREE_KB ; sectors = $FREE_SEC)"
DATA_FS=$(sgdisk --print $MMC | awk ' $1 == "29" { print $2}')
DATA_LS=$(sgdisk --print $MMC | awk ' $1 == "29" { print $3}')
SYS_FS=$(sgdisk --print $MMC | awk ' $1 == "30" { print $2}')
SYS_LS=$(sgdisk --print $MMC | awk ' $1 == "30" { print $3}')
echo "Data partition first sector: $DATA_FS"
echo "Data partition last sector: $DATA_LS"
echo "System partition first sector: $SYS_FS"
echo "System partition last sector: $SYS_LS"
let NEW_DATA_LS=$DATA_LS+$FREE_SEC-$NEW_FREE_SEC
let NEW_SYS_FS=$NEW_DATA_LS+1
echo "Data partion NEW last sector: $NEW_DATA_LS"
echo "System partion NEW first sector: $NEW_SYS_FS"
-------------------------------
Output:
/external_sd # . resize_partions
Your system partion has 839 mbyte free ( kbyte = 859392 ; sectors = 1718784)
Data partition first sector: 1449984
Data partition last sector: 10043391
System partition first sector: 10043392
System partition last sector: 15269375
Data partion NEW last sector: 11696639
System partion NEW first sector: 11696640
-------------------------------
Next things to code would be:
- Backup both partitions to SD-card using "tar" ( tar cpf ...)
- unmount partitions
- delete partitions ( sdisk $MMC --delete 30 )
- create partitions with new sector boundaries ( sgdisk $MMC --new 30:11696640:15269375 )
- change partition type ( sgdisk $MMC -t 30:8300)
- change name ( sgdisk $MMC --change-name 30:"system")
- create ext4 partion ( make_ext4fs -L system /dev/block/mmcblk0p30)
- mount
- restore partions ( tar xpf ..)
Do i need special options for make_ext4fs ?
But the question is: would this work ??? What, if i bootloop my device ?
klarseher said:
Hello,
i've startet coding a shell script:
------------------------------------------------------------
#!/bin/bash
MMC=/dev/block/mmcblk0
NEW_FREE_SEC=65536 # 32 mbyte in sectors
if [ $(id -u) -ne 0 ]; then
echo "Only root is allowed"
exit
fi
mount | grep "$MMC" > /dev/null
RC=$?
if [ $RC -eq 1 ]; then
echo "system not mounted. mounting now"
mount /system
RC=$?
echo $RC
fi
FREE_MB=$(df -P -m /system/ | grep 'mmcblk0p30' | awk '{print $4}')
FREE_KB=$(df -Pk /system/ | grep 'mmcblk0p30' | awk '{print $4}')
FREE_SEC=$(df -P -B 512 /system/ | grep 'mmcblk0p30' | awk '{print $4}')
echo "Your system partion has $FREE_MB mbyte free ( kbyte = $FREE_KB ; sectors = $FREE_SEC)"
DATA_FS=$(sgdisk --print $MMC | awk ' $1 == "29" { print $2}')
DATA_LS=$(sgdisk --print $MMC | awk ' $1 == "29" { print $3}')
SYS_FS=$(sgdisk --print $MMC | awk ' $1 == "30" { print $2}')
SYS_LS=$(sgdisk --print $MMC | awk ' $1 == "30" { print $3}')
echo "Data partition first sector: $DATA_FS"
echo "Data partition last sector: $DATA_LS"
echo "System partition first sector: $SYS_FS"
echo "System partition last sector: $SYS_LS"
let NEW_DATA_LS=$DATA_LS+$FREE_SEC-$NEW_FREE_SEC
let NEW_SYS_FS=$NEW_DATA_LS+1
echo "Data partion NEW last sector: $NEW_DATA_LS"
echo "System partion NEW first sector: $NEW_SYS_FS"
-------------------------------
Output:
/external_sd # . resize_partions
Your system partion has 839 mbyte free ( kbyte = 859392 ; sectors = 1718784)
Data partition first sector: 1449984
Data partition last sector: 10043391
System partition first sector: 10043392
System partition last sector: 15269375
Data partion NEW last sector: 11696639
System partion NEW first sector: 11696640
-------------------------------
Next things to code would be:
- Backup both partitions to SD-card using "tar" ( tar cpf ...)
- unmount partitions
- delete partitions ( sdisk $MMC --delete 30 )
- create partitions with new sector boundaries ( sgdisk $MMC --new 30:11696640:15269375 )
- change partition type ( sgdisk $MMC -t 30:8300)
- change name ( sgdisk $MMC --change-name 30:"system")
- create ext4 partion ( make_ext4fs -L system /dev/block/mmcblk0p30)
- mount
- restore partions ( tar xpf ..)
Do i need special options for make_ext4fs ?
But the question is: would this work ??? What, if i bootloop my device ?
Click to expand...
Click to collapse
try and give info
Flashing stock with Flashtool should restore official partition table.
bootloop now ...
ch3mn3y said:
Flashing stock with Flashtool should restore official partition table.
Click to expand...
Click to collapse
As a first step, I have only risized the system partition. The files were backuped with "tar cpf" and restored with "tar xpf" in the recreated partition.
I could see the files in the partion, but the phone does not startup "normal".
I had to use the hidden off button near the SD-slot to power off the phone. Flashing didn't resolved the problem. There is an error while writing system.sin - probably because the partition is to small.
Maybe i have to downgrade flashtool, as mentioned in http://forum.xda-developers.com/showpost.php?p=62751375&postcount=3 ???
Next step would be to "unbrick" my phone. With original system partition, i will only backup and restore the content, to see, if "tar" is able to do the job. Second try with TWRP Backup.
Hello,
I could be wrong, but I think your bootloop problem would probably comes from some sort of SONY extra protection layer.
This additional security system is called RIC and prevents you from freely modifying the system partition at runtime by blocking r/w mount of the system partition.
There is also a default Android security that checks the system partition against a hardcoded hash on boot, to prevent system partition modification (maybe partition size is part of the check operation...).
So you may try to disable the first protection (look at Z5 tutorial) and/or look for a way to bypass the boot check (not sure if possible).
Regards.
system parttion successfull shrinked
Okay, i finally shrinked my system partition and the phone will boot up normal.
The process is a little bit complicated.
You have to create a TWRP backup of your debloated system partition.
Check, if this backup is working ! So rm -rf everything in system and restore from backup.
Next, delete partition with sgdisk and create smaler one ( my script from 1st post will do the calculation for 1st sector )
Change name of partion to "system".
Create ext4 fileystem on parttion ( TWRP will also format - don't know if realy needed )
Reboot into TWRP an try to restore - maybe reboot some times into TWRP and check parttions
To recover with flashtool in case you didn't manage to get it to work - delete system partition and flash "partition.sin" and "system.sin"
In the next step, i will increase data partition
Code:
/system # df -h .
Filesystem Size Used Available Use% Mounted on
/dev/block/mmcblk0p30
1.6G 1.6G 4.9M 100% /system
/system # sgdisk --print /dev/block/mmcblk0 | tail -10
21 393216 475135 40.0 MiB FFFF FOTAKernel
22 475136 475151 8.0 KiB FFFF ssd
23 475152 475215 32.0 KiB FFFF DDR
24 475216 476239 512.0 KiB FFFF config
25 476240 509007 16.0 MiB 8300 LTALabel
26 516096 532479 8.0 MiB 8300 apps_log
27 532480 1040383 248.0 MiB 8300 oem
28 1040384 1449983 200.0 MiB 8300 cache
29 1449984 10043391 4.1 GiB 8300 userdata
30 11702880 15269375 1.7 GiB 8300 system
/system #
klarseher said:
Okay, i finally shrinked my system partition and the phone will boot up normal.
The process is a little bit complicated.
You have to create a TWRP backup of your debloated system partition.
Check, if this backup is working ! So rm -rf everything in system and restore from backup.
Next, delete partition with sgdisk and create smaler one ( my script from 1st post will do the calculation for 1st sector )
Change name of partion to "system".
Create ext4 fileystem on parttion ( TWRP will also format - don't know if realy needed )
Reboot into TWRP an try to restore - maybe reboot some times into TWRP and check parttions
To recover with flashtool in case you didn't manage to get it to work - delete system partition and flash "partition.sin" and "system.sin"
In the next step, i will increase data partition
Code:
/system # df -h .
Filesystem Size Used Available Use% Mounted on
/dev/block/mmcblk0p30
1.6G 1.6G 4.9M 100% /system
/system # sgdisk --print /dev/block/mmcblk0 | tail -10
21 393216 475135 40.0 MiB FFFF FOTAKernel
22 475136 475151 8.0 KiB FFFF ssd
23 475152 475215 32.0 KiB FFFF DDR
24 475216 476239 512.0 KiB FFFF config
25 476240 509007 16.0 MiB 8300 LTALabel
26 516096 532479 8.0 MiB 8300 apps_log
27 532480 1040383 248.0 MiB 8300 oem
28 1040384 1449983 200.0 MiB 8300 cache
29 1449984 10043391 4.1 GiB 8300 userdata
30 11702880 15269375 1.7 GiB 8300 system
/system #
Click to expand...
Click to collapse
give flashable zip
Increasing userdata worked the same way. Backup userdata with TWRP, delete partition 29, create partition 29 with new last sector. Restore with TWRP.
( I've lost adoptive storage in this step - but this is okay, because adoptive storage is to slow for me )
Now userdata on my phone has 4.9 GIB.
To do the same, you have to read and understand.
There is no flashable zip - you will resize your partitions after removing unused stuff from system partition. You have to deal with sgdisk on the TWRP cmdline ( adb shell)
klarseher said:
Hello,
my phone is an E2303. The only problem for me with this phone is the limited memory.
I have rooted the phone the way explained in http://forum.xda-developers.com/m4-a.../root-t3421932
With Root Explorer, i removed a lot of stuff in /system. Now 1,66 GB are used and 810 MB are free.
usderdata and system partitions ( sgdisk --print /dev/block/mmcblk0 )
Nr Name Start Stop Size type
29 userdata 1449984 10043391 4.1 GIB 8300
30 system 10043392 15269375 2.5 GIB 8300
My idea:
- use TWRP to backup userdata and system partions
- delete both partitions
- create userdata with 4.6 GIB
- create system with 2 GIB
- format both partitions with make_extfs4
- restore both partitions with TWRP
I know that as a consequence, i'm not able to flash updates.
Do you think, that this would work ?
Click to expand...
Click to collapse
When you remove or delete any system app the folder & ink may get deleted but odex file of original stock rom remains in odex folder as squashed this way you can free up at least 200 to 300 mb.
I have tested it on LP.
& As per my assumption the squashed odexes got nothing to do with selinux as it only load images from squashed folder.
rebuild odex.system.sqsh
Hello,
I rebuild odex.system.sqsh - the size has been reduced from 275MByte to 151MByte.
but, my current linux distribution does not support selinux
So, i have to repeat with another linux distribution and replace odex.system.sqsh in /system folder.
maybe next weekend ...
howto
klarseher said:
Hello,
I rebuild odex.system.sqsh - the size has been reduced from 275MByte to 151MByte.
but, my current linux distribution does not support selinux
So, i have to repeat with another linux distribution and replace odex.system.sqsh in /system folder.
maybe next weekend ...
Click to expand...
Click to collapse
The solution:
- install CentOS 7 in VirtualBox
Get odex.system.sqsh from phone ( Phone in TWRP Mode):
adb pull /system/odex.system.sqsh .
Copy odex.system.sqsh to CentOS ( via shared folder)
As root:
- yum install squashfs-tools
- unsquashfs odex.system.sqsh # you got a lot of warnings, because unsquashfs is not allowed to access selinux attributes
- rm -rf squashfs-root # remove for next try
- grep unsquashfs /var/log/audit/audit.log | audit2allow -M mypol
- semodule -i mypol.pp
- unsquashfs odex.system.sqsh
Now, remove unused stuff inside squashfs-root folder
mksquashfs squashfs-root/ odex.system-new.sqsh -comp xz -noI -noF -noX -no-fragments -no-duplicates
---
In TWRP -adb shell:
cd /system
touch dummy
chcon --reference=system.odex.sqsh dummy
rm system.odex.sqsh
# Copy from pc with
adb put odex.system-new.sqh /system/
Back in adb shell:
mv odex.system-new.sqh odex.system.sqh
chcon --reference=dummy system.odex.sqsh
---
The cleanaup in squashfs-root depends on you debloating. I have build my delete script on file lists from /system before and after removing unwanted apps. ( diff before/after | grep '\.odex$')
As a final step, i shrinked my system partion to 1.5 GB ( from original 2.5) and increased /data to 5.1 GB.
Very cool and great job! Maybe try making a step by step tutorial during your free time? Could benefit us all
partitions in DiskInfo
See layout of /data and /system partitions on my phone
klarseher said:
See layout of /data and /system partitions on my phone
Click to expand...
Click to collapse
Very cool and great job!
Please making a step by step tutorial for all !!! Thanks !
manhquyet90 said:
Very cool and great job!
Please making a step by step tutorial for all !!! Thanks !
Click to expand...
Click to collapse
Thanks !
Boot phone into TWRP
1. create a backup of your system partition with TWRP
2. "adb shell" to your phone (still booted in TWRP) and create a filelist from system partion on your SD card ( "mount /system ; find /system -type f > /external_sd/system_filelist.lst" - unsure about path to your SD-card )
( we need filelist later for odex "cleanup" )
3. "debloat" your system partition - there are some threads in this forum about removing stuff from /system - i could not help you with this task !
Boot phone into TWRP
4. "adb shell" to your phone. Come back with the output of "mount /system ; df -k /system" and "sgdisk --print /dev/block/mmcblk0"
( I will calculate the new first sector for the system partition depending on your free space )
Then, we do the next step together !
Kind regards
klarseher said:
Thanks !
Boot phone into TWRP
1. create a backup of your system partition with TWRP
2. "adb shell" to your phone (still booted in TWRP) and create a filelist from system partion on your SD card ( "mount /system ; find /system -type f > /external_sd/system_filelist.lst" - unsure about path to your SD-card )
( we need filelist later for odex "cleanup" )
3. "debloat" your system partition - there are some threads in this forum about removing stuff from /system - i could not help you with this task !
Boot phone into TWRP
4. "adb shell" to your phone. Come back with the output of "mount /system ; df -k /system" and "sgdisk --print /dev/block/mmcblk0"
( I will calculate the new first sector for the system partition depending on your free space )
Then, we do the next step together !
Kind regards
Click to expand...
Click to collapse
Code:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\MQ>adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
YT911B19A1 recovery
C:\Users\MQ>adb shell
~ # ←[6nmount /system
~ # ←[6nfind /system -type f > /external_sd/system_filelist.lst
~ # ←[6nmount /system
mount: mounting /dev/block/mmcblk0p30 on /system failed: Device or resource busy
~ # ←[6ndf -k /system
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/block/mmcblk0p30
2531076 2448068 66624 97% /system
~ # ←[6nsgdisk --print /dev/block/mmcblk0
CANNOT LINK EXECUTABLE: cannot locate symbol "__register_atfork" referenced by "
sgdisk"...
page record for 0x7f91ab0010 was not found (block_size=64)
~ # ←[6n

Ubuntu, Arch Linux, Tails on Acer Chromebook C720P & Asus CS10 Chromebook stick

placeholder
I will try & summarise all my works to install Linux distros on USB's or using crouton on Chromebooks...
Make sure you are in developer mode...
1. crouton
Download crouton in ~/Downloads
Useful command in Chrome/Chromium OS to install crouton Linux distro ubuntu xenial with xfce & xiwi in Acer Chromebook C720P
in a ctrl-alt-t shell -
shell
sudo sh ~/Downloads/crouton -r xenial -t xfce,xiwi,touch,extension
After running the command, one should get the following message (generally)
Here's some tips:
Audio from the chroot will now be forwarded to CRAS (Chromium OS audio server),
through an ALSA plugin.
Future Chromium OS upgrades may break compatibility with the installed version
of CRAS. Should this happen, simply update your chroot.
You already have the Chromium OS extension installed, so you're good to go!
You can open your running chroot desktops by clicking on the extension icon.
Once in a crouton window, press fullscreen or the "switch window" key to switch
back to Chromium OS.
You can launch individual apps in crouton windows by using the "xiwi" command
in the chroot shell. Use startxiwi to launch directly from the host shell.
Use the startxiwi parameter -b to run in the background.
Example: sudo startxiwi -b xterm
You can start Xfce via the startxfce4 host command: sudo startxfce4
Unmounting /mnt/stateful_partition/crouton/chroots/xenial...
Sending SIGTERM to processes under /mnt/stateful_partition/crouton/chroots/xenial...
Done! You can enter the chroot using enter-chroot.
( to use xiwi, you need to install the crouton extension from the Google Web Store).
Not re-inventing the wheel, head on for further info to:
Complete Crouton Installation Guide (Linux on any Chromebook):
https://www.codedonut.com/chromebook/install-crouton-chromebook/
& the dev's crouton's github:
https://github.com/dnschneid/crouton
In case the crouton chroot is already installed without xiwi,
To update an installation with xiwi, apply:
sudo sh ~/Downloads/crouton -n xenial -t xfce,xiwi,touch,extension -u
Notes:
cons -
with crouton one is stuck with the Chrome OS host Linux Kernel , which for Acer CB C720P is Kernel v3.8
it is a chroot environment, so new Ubunture features such as snap packaging cannot be used.
pros -
xiwi allows running Linux apps in separate windows
share of the clipboard & ~/Downloads folder between host & guest
one does not leave the Chrome OS environment
it is like the new crostini feature they are pushing on Kernel 3.18 & above
I think crostini is crouton in Italian
Chromebrew
All I have to say about skycocker's chromebrew -
For a full arsenal of Linux commands at your fingertips in a crosh shell, install Chromebrew package manager on Chromebook or Chrome OS -
requisites: developer mode enabled.
https://github.com/skycocker/chromebrew …
curl -Ls http://git.io/vddgY | bash
crew <command> [-k|--keep] <package1> ...]
Note -
sad but true, I installed chromebrew to get access to the nano text editor - as I have never made the effort to master vi/vim despite using Linux since 1995...
Tails Linux distro with Tor privacy
Tails is an operating system based on Linux & the Tor anonymity project.
It's easy to install on a USB, & very portable as it can boot off MBR & EFI partitions.
It's only available for x86 & x86_64 computers, though they are looking into porting it to Arm.
I got it on a USB following instructions in the developers website: https://tails.boum.org/
Tor browser on any computer, Linux, Mac, Windows, Android.
1. relevant to Chromebooks or hacked with Android & Play Store - Orbot / Orfox:
Tor anonymising solution is now available on Play Store - the Tor proxy is called Orbot & a web browser was compiled to run with it based on mozilla firefox called Orfox.
The set Orbot / Orfox are available to download for free from the Play Store -
I won't describe any of it -
Initially before it was on Play Store, it could be downloaded from the devs group who ported it to Android it: https://guardianproject.info/apps/orbot/
It was also made available through an open source Android Store: F-Droid - https://guardianproject.info/fdroid/
F-Droid is a great source for free open source alternative Android software - it works seamlessly through the Android platform or within proprietary Android based like Amazon Fire.
2. For other x86 platforms like Windows, Linux, Mac...
all is in here: https://www.torproject.org/
F-Droid - a great open source software repository for Android applications
Great way to complement Amazon Appstore, or Android Play Store is F-Droid -
a software repository for Android applications, similar to Google Play store.
The main repository, hosted by the project, contains only apps that are free and open-source software.
https://f-droid.org/en/
https://twitter.com/inabster/status/956226183477317633
F-Droid have a repository for a Tor powered solution on Android platform worthy to those concerned about privacy Orbot is the open source app, & Orfox is the associated Tor Mozilla based (Firefox fork) browser - https://guardianproject.info/apps/orbot/ https://guardianproject.info/apps/orfox/
https://twitter.com/inabster/status/956229034169520130
Ubuntu on Chromebook from USB.
Seabios emulates an mbr boot, so allows booting to mbr using Ctrl-L
Ubuntu then installs as normal to mbr using a Ubuntu livecd.
It might be possible to install Ubuntu so it boots using Ctrl-U. I did not look into it.
Arch Linux on Chromebook & Asus Chromebit CS10
Arch Linux on Asus Chromebit CS10 -
Full instructions here:
https://archlinuxarm.org/platforms/armv7/rockchip/asus-chromebit-cs10
Mainline Kernel
The installation above will use the ChromeOS 3.14 kernel. The mainline kernel can be used instead, though some hardware may not be working yet. Two options are available to switch to the mainline kernel:
Replace kernel packages after installation
Install linux-armv7 packages, replacing the linux-veyron package, and the firmware-veyron package:
pacman -S linux-armv7 linux-armv7-chromebook firmware-veyron
Type y and hit enter when prompted to flash the kernel to the kernel partition.
Remove the veyron-libgl and xf86-video-armsoc-rockchip packages. Mali is not supported in mainline.
pacman -R veyron-libgl xf86-video-armsoc-rockchip
Reboot.
Perform a new installation with the above steps using the armv7-chromebook tarball:
http://os.archlinuxarm.org/os/ArchLinuxARM-armv7-chromebook-latest.tar.gz
Install the firmware-veyron package, or copy it to the drive for later installation for wifi support.
pacman -S firmware-veyron
Arch Linux on Chromebook -
Easiest instructions to install Arch Linux on a USB of Chromebook in BIOS legacy mode here:
https://gist.github.com/alphazo/3285090
https://twitter.com/inabster/status/692098848391610372
General consideration on Linux installs with uefi - notes to self
These are notes to myself to link up to - I have posted them on @twitter - but nice to have them ready for copy & paste.
Not related to Chromebooks generally, unless one uses Ctrl-U which is an uefi boot... I did not dabble in it...
Two important config files to get a successful Arch Linux or Ubuntu boot are:
grub.cfg
fstab
fstab is in /etc/
/etc/fstab
& tells the OS where relevant partitions are
... TBC
Linux Kernel related building commands for reference...
Build Ubuntu Kernel
sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc
clone git kernel for source in home user folder ~/kernel
cd kernel
cp /boot/config-$(uname -r) .config
make menuconfig
sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
sudo update-initramfs -c -k 4.xx.xx
sudo update-grub .../...
also
build kernel headers from source with: (at root of kernel directory) -
sudo make headers_install INSTALL_HDR_PATH=/usr/include
Arch Linux 4.19-LTS & 5.0.8 nasty bug
Testing Arch Linux on Chromebook
Arch Linux 4.19-LTS & 5.0.8 nasty bug
but for those using Arch Linux, avoid kernel 4.19-LTS & 5.0.8 like the plague,
both damage Arch Linux by disabling usb input devices, trackpad, mouse, keybooard, touch...
I had to put my rant somewhere, it damaged a 3 year Arch Linux USB stick for me
Since I am here, might as well post for reference my experience with getting a new USB loaded with Arch Linux
not doing it from scratch, too much effort...
found this - quite good too, Live USB persistent -
Arch Linux USB OS https://sourceforge.net/projects/arch-linux-usb-os/ …
It saves the trouble of building Arch Linux OS from scratch.
Uses Kernel 5.0.5 -
Linux robot 5.0.5-arch1-1-ARCH #1 SMP PREEMPT Wed Mar 27 17:53:10 UTC 2019 x86_64 GNU/Linux
if allowed to upgrade to 5.0.8 will bork the input, so only upgrade to 5.0.7 maximum (linux-rt), which I built through aur.
upgrading through aur to linux-rt 5.0.7
$ uname -a
Linux robot 5.0.7-rt5-1-rt #1 SMP PREEMPT RT Mon Apr 22 14:42:29 CEST 2019 x86_64 GNU/Linux
to get to boot with this kernel needs to replace linux with linux-rt in loader settings.
to stop kernel from upgrading -
ArchLinux is updated to the newest version with the command:
pacman -Syu
To stop it from updating the kernel (until they get their **** together) add
IgnorePkg = linux linux-headers
into /etc/pacman.conf
stuff / thingies
[email protected] ~ $ cd /run/archiso/bootmnt
[email protected] bootmnt $ ls
arch EFI loader
[email protected] bootmnt $ ls arch/boot
amd-ucode.img grub intel-ucode.img intel_ucode.LICENSE x86_64
[email protected] bootmnt $ ls arch/boot/x86_64/
initramfs-linux.img initramfs-linux-rt.img vmlinuz-linux vmlinuz-linux-rt
notes -
original shipped linux version is 5.0.5
upgraded linux version though aur is linux-rt 5.0.7
so needed to copy vmlinuz-linux-rt & initramfs-linux-rt.img to /run/archiso/bootmnt/arch/boot/x86_64/
cannot be done from a running instance, so had to boot from another live usb to copy it over from
[email protected] bootmnt $ ls /boot
amd-ucode.img initramfs-linux-rt-fallback.img syslinux
grub initramfs-linux-rt.img vmlinuz-linux
initramfs-linux.img intel-ucode.img vmlinuz-linux-rt
to automate replace loading linux with linux-rt, modify
/run/archiso/bootmnt/loader/entries/
[email protected] entries $ ls
Archlinux.conf Archlinux-terminal.conf uefi-shell-v2-x86_64.conf
Archlinux-copytoram.conf uefi-shell-v1-x86_64.conf
example
Archlinux.conf original
title Arch Linux UEFI
linux /arch/boot/x86_64/vmlinuz-linux
initrd /arch/boot/intel-ucode.img
initrd /arch/boot/amd-ucode.img
initrd /arch/boot/x86_64/initramfs-linux.img
options archisobasedir=arch archisolabel=USB-BOOT cow_label=usb-save loglevel=3
change to:
title Arch Linux UEFI
linux /arch/boot/x86_64/vmlinuz-linux-rt
initrd /arch/boot/intel-ucode.img
initrd /arch/boot/amd-ucode.img
initrd /arch/boot/x86_64/initramfs-linux-rt.img
options archisobasedir=arch archisolabel=USB-BOOT cow_label=usb-save loglevel=3
to be able to modify bootloader files
do above from a separate linux usb (mine is Ubuntu 18.04)
$ mkdir efi
$ sudo mount /dev/sdb1 efi
$ cd efi
$ ls
arch EFI loader
... etc as above.
News - Arch Linux released Kernel 5.0.9 - still has the nasty bug - do not upgrade, if you did, downgrade by installing the downgrade script from aur...
How to downgrade a Linux kernel...
https://arcolinux.com/how-to-downgrade-a-linux-kernel/
Borking my 3 year arch linux USB was a blessing in disguise, made me look for a persistent USB alternative...
the one described above boots Acer Chromebook C720P well, it works great, with kernels 5.0.5 & 5.0.7 -
I tested it on the modded full ROM MrChromebox firmware, but believe it will work as well in Seabios legacy mode.
notes to myself
Linux pot-pourri commands from my notes, for reference
these are copy & paste commands which I need put into one place, here...
I will rearrange them later with context where to be used...
placeholder...
Chromebook: Updating xenial to bionic w/ crouton:
$ sudo enter-chroot -n xenial
(xenial)[email protected]:~$ sudo apt-get install update-manager-core python-apt
(xenial)[email protected]:~$ sudo do-release-upgrade
$ sudo sh ~/Downloads/crouton -n xenial -u
$ sudo edit-chroot xenial -m bionic
Creating a dev environment in all Chrome OS x86 or arm:
shell
sudo dev_install
Creating a Visual Studio environment in arm:
shell
sudo su -
. <( curl -s https://code.headmelted.com/installers/chromebook.sh … )
Creating a Ubuntu chroot & X-Windows environment:
sudo sh ~/Downloads/crouton -t xfce -r xenial
If using rEFInd as bootloader, a useful command to get entries at boot in the UEFI menu is:
$ sudo efibootmgr -c -g -d /dev/sda -p 1 -w -L "rEFInd" -l '\EFI\refind\refind_x64.efi'
replace /dev/sda by /dev/sdx x=b,c... in other cases.
To check install is correct, issue:
$ [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD]
Sometimes needed
1.:
$ sudo apt-get install --reinstall efibootmgr
$ sudo grub-install /dev/sda
$ sudo apt-get install --reinstall grub-efi
$ sudo grub-install /boot/efi
$ sudo grub-install --target=i386-efi /dev/sda1 --efi-directory=/boot/efi/ --boot-directory=/boot
2.:
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
then again:
$ sudo apt-get -y install --reinstall grub-efi-ia32 grub-efi-ia32-bin
@ubuntu 18.04.1 works with efi on @bbenTech Intel Compute Stick (ICS) cherrytrail clone & with mbr (seabios legacy) on @Acer Chromebook C720P.
Managed to get it to boot w/ efi 32bit bootlader - but I had to get into GUI 1st & bypass the initramfs emergency mode - what was needed was correct UUID of EFI partition in /etc/fstab - then boot through grub manually...
UUID=XXXX-XXXX /boot/efi vfat umask=0077 0 1
When in grub, issue
set root=(hd0,gpt2)
configfile (hd0,gpt1)/efi/ubuntu/grub.cfg
(grub.cfg must have the UUID of (hd0,gpt2) in my case of /dev/sdb2
use
sudo blkid /dev/sdX to find UUID's)
that boots into Ubuntu 18.04
open terminal...
When in the GUI
in terminal issue:
sudo apt-get update
sudo apt-get -y install --reinstall grub-efi-ia32 grub-efi-ia32-bin
reboot
Notes:
Arch Linux
$ sudo grub-install --target=i386-efi /dev/sda2 --efi-directory=/boot/efi/ --boot-directory=/boot
$ sudo efibootmgr -c -g -d /dev/sda -p 2 -w -L "Arch" -l '\EFI\EFI\arch\grubia32.efi'
then:
$ sudo grub-mkconfig -o /boot/EFI/EFI/arch/grub.cfg
$ sudo mkinitcpio -p linux
from http://www.rodsbooks.com/efi-bootloaders/installation.html#alternative-naming
Arch Linux mainline kernel
$ sudo mount -o remount,size=6G,noatime /tmp
$ yaourt linux-mainline
more crouton / crostini stuff
Latest crostini kernel is 4.19.16 -
for lolz I installed mplayer, mpv & gnome-mpv (all Linux video players)
they do load videos from crostini, but with no sound (this is using cyan & eve v73) -
of course video works great in crouton Linux distros... or in Android with VLC etc...
RFC - Any idea how to get sound working through crostini?
of course this is not needed as within Android or crouton with say Ubuntu bionic, sound is perfectly fine
just fooling around crostini
from - https://forum.xda-developers.com/showpost.php?p=79527257&postcount=215
crouton bionic sound issues -
add following to /etc/pulse/daemon.conf -
default-sample-rate = 48000
default-fragments = 5
default-fragment-size-msec = 2
Access audio hardware directly (ALSA, JACK)
add yourself to the hwaudio group.
sudo usermod -a -G hwaudio "$USER"
Log out and log back in.
Test:
$ groups
slee2 hwaudio video sudo plugdev audio input
Stop CRAS
Make sure you've stopped CRAS, or else it will hold on to your audio device. In either ChromeOS or your chroot, run
$ sudo initctl stop cras
You might also need this to control audio -
$ alsamixer -c 0
from - https://github.com/dnschneid/crouton/wiki/Access-audio-hardware-directly-(ALSA,-JACK)
& https://github.com/dnschneid/crouton/wiki/Audio
Reinstall GRUB to the EFI partition using chroot
Notes to self-
sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub
Note : sdX = disk | sdXX = efi partition | sdXXX = system partition
To identify the partitions use GParted, the tool is included in the installation medium.
After having run the commands GRUB will be installed in the separate EFI partition.
Deploying, bootloading OSes such as Ubuntu manually
I like to initially install an OS to a 16/32 GB USB 3.0 stick, then dd it to a bigger SSD of I am happy with it, follows some notes on how it is done...
In previous post, I described how to fix an efi booting, but there is a caveat, one needs to know where & how to modify settings of efi bootlader, & /etc/fstab that tells the OS where to find partitions to load itself (bootstrap)...
These are some successful partition settings I had to deal with -
1. efi/mbr mix
$ sudo fdisk -l
Disk /dev/sdb: 465.8 GiB, 500107861504 bytes, 976773167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: ***
Device Start End Sectors Size Type
/dev/sdb1 2048 411647 409600 200M EFI System
/dev/sdb2 411648 210208767 209797120 100G Microsoft basic data
/dev/sdb3 210415616 337403903 126988288 60.6G Linux filesystem
/dev/sdb4 337403904 430872575 93468672 44.6G Linux filesystem
/dev/sdb5 430872576 435066879 4194304 2G Linux swap
/dev/sdb6 435066880 624490495 189423616 90.3G Microsoft basic data
/dev/sdb7 624490496 976766975 352276480 168G Microsoft basic data
/dev/sdb8 210208768 210415615 206848 101M BIOS boot
Partition table entries are not in disk order.
/dev/sdb8 is BIOS boot invoked by bios_grub flag in gparted manage flags partition editor
/dev/sdb1 is efi partition flagged as boot, esp & legacy_boot in gparted manage flags partition editor
$ sudo fdisk -l
Disk /dev/sdc: 931.5 GiB, 1000204885504 bytes, 1953525167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxx
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M BIOS boot
/dev/sdc2 206848 135235583 135028736 64.4G Linux filesystem
/dev/sdc3 135235584 286480383 151244800 72.1G Linux filesystem
/dev/sdc4 286480384 599062527 312582144 149.1G Microsoft basic data
/dev/sdc5 599062528 599984127 921600 450M Windows recovery environment
/dev/sdc6 599984128 1007575039 407590912 194.4G Microsoft basic data
/dev/sdc7 1007575040 1949327359 941752320 449.1G Microsoft basic data
/dev/sdc8 1949329408 1953103871 3774464 1.8G Linux swap
/dev/sdc9 1953105920 1953519615 413696 202M EFI System
/dev/sdc1 is BIOS boot invoked by bios_grub flag in gparted manage flags partition editor
/dev/sdc9 is efi partition flagged as boot, esp & legacy_boot in gparted manage flags partition editor
2. pure mbr / no BIOS boot - using Windows boot loader & easyBCD 3.2 to load Linux/Ubuntu
$ sudo fdisk -l
Disk /dev/sdc: 931.5 GiB, 1000204885504 bytes, 1953525167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x767e7d2d
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 472768511 472766464 225.4G 7 HPFS/NTFS/exFAT
/dev/sdc2 472768512 1422079999 949311488 452.7G 7 HPFS/NTFS/exFAT
/dev/sdc3 1422080221 1479591932 57511712 27.4G 83 Linux
/dev/sdc4 1479591933 1953523711 473931779 226G f W95 Ext'd (LBA)
/dev/sdc5 1479591936 1949331455 469739520 224G 83 Linux
/dev/sdc6 1949333504 1953523711 4190208 2G 82 Linux swap / Solaris
3. pure mbr (just Ubuntu, nothing else)
$ sudo fdisk -l
Disk /dev/sdc: 14.6 GiB, 15693664256 bytes, 30651688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2BB06DCE-2D30-4778-94BD-2FD214CD3C3B
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M BIOS boot
/dev/sdc2 206848 28555263 28348416 13.5G Linux filesystem
/dev/sdc3 28555264 30650367 2095104 1023M Linux swap
In 3. this is what to expect when you install Ubuntu to mbr, it will ask you to also create a BIOS boot partition of at least 1 MB - I chose here 100 MB to safeguard for future change, it's kind of a blob with core image for booting...
4. pure efi (just Ubuntu & EFI partition, nothing else)
$ sudo fdisk -l
Disk /dev/sdc: 29.3 GiB, 31406948352 bytes, 61341696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0B9FB340-99D5-03A3-D0EC-E74275E6E800
Device Start End Sectors Size Type
/dev/sdc1 2048 411647 409600 200M EFI System
/dev/sdc2 411648 58195967 57784320 27.6G Linux filesystem
/dev/sdc3 58195968 61335551 3139584 1.5G Microsoft basic data
in 4. I prep a disk with the three partitions EFI, ROOT & SWAP Assign the flags for the EFI partition as as boot, esp & legacy_boot in gparted, then use an install dvd/usb disk to install by assigning the correct partitions...
3 & 4 I use to deploy, if it's just them, I just dd to a bigger disk,
if not, I use the ROOT to dd to a partition in a target partition in a bigger disk that is already populated with say Windows or OS X, or any other,
care has then to be taken not to disturb the initial order,
so ROOT for Ubuntu should be put at the end of the original installations, etc.
In the next post I will take an example & walk through it...
efi/mbr partitions in pictures
1. efi/mbr mix
https://forum.xda-developers.com/attachment.php?attachmentid=4779410&stc=1&d=1560960108
https://forum.xda-developers.com/attachment.php?attachmentid=4779411&stc=1&d=1560960108
2. pure mbr / no BIOS boot - using Windows boot loader & easyBCD 3.2 to load Linux/Ubuntu
https://forum.xda-developers.com/attachment.php?attachmentid=4779413&stc=1&d=1560960108
3. pure mbr (just Ubuntu, nothing else)
https://forum.xda-developers.com/attachment.php?attachmentid=4779412&stc=1&d=1560960108
4. pure efi (just Ubuntu & EFI partition, nothing else)
https://forum.xda-developers.com/attachment.php?attachmentid=4779414&stc=1&d=1560960108
pictures in @twitter feeds -
https://twitter.com/inabster/status/1141482400112926723
https://twitter.com/inabster/status/1141482980151615488
RFC - how do we get the pictures to appear in the posts?
Bootloading examples
Method in post #13 required to have both the efi & bios boot partitions present
https://forum.xda-developers.com/showpost.php?p=79742668&postcount=13
This is a set piece for
Device Start End Sectors Size Type
/dev/sdb1 2048 411647 409600 200M EFI System
/dev/sdb2 411648 210208767 209797120 100G Microsoft basic data
/dev/sdb3 210415616 337403903 126988288 60.6G Linux filesystem
/dev/sdb4 337403904 430872575 93468672 44.6G Linux filesystem
/dev/sdb5 430872576 435066879 4194304 2G Linux swap
/dev/sdb6 435066880 624490495 189423616 90.3G Microsoft basic data
/dev/sdb7 624490496 976766975 352276480 168G Microsoft basic data
/dev/sdb8 210208768 210415615 206848 101M BIOS boot
sudo mount /dev/sdb3 /mnt
sudo mount /dev/sdb1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdb
update-grub
2nd example -
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M BIOS boot
/dev/sdc2 206848 135235583 135028736 64.4G Linux filesystem
/dev/sdc3 135235584 286480383 151244800 72.1G Linux filesystem
/dev/sdc4 286480384 599062527 312582144 149.1G Microsoft basic data
/dev/sdc5 599062528 599984127 921600 450M Windows recovery environment
/dev/sdc6 599984128 1007575039 407590912 194.4G Microsoft basic data
/dev/sdc7 1007575040 1949327359 941752320 449.1G Microsoft basic data
/dev/sdc8 1949329408 1953103871 3774464 1.8G Linux swap
/dev/sdc9 1953105920 1953519615 413696 202M EFI System
sudo mount /dev/sdc3 /mnt
sudo mount /dev/sdc9 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdc
update-grub
out of chroot, these commands are also useful:
sudo efibootmgr -c -g -d /dev/sdc -p 9 -w -L "ubuntu" -l '\EFI\refind\refind_x64.efi' #efi partition /dev/sdc9
sudo grub-install /boot/efi # this after having mounted in /etc/fstab /dev/sdc9 in /boot/efi
sudo efibootmgr -c -g -d /dev/sdb -p 1 -w -L "ubuntu" -l '\EFI\refind\refind_x64.efi' #efi partition /dev/sdb1
sudo grub-install --target=x86_64-efi /dev/sdb3 --efi-directory=/boot/efi/ --boot-directory=/boot
sudo grub-install --target=x86_64-efi /dev/sdc3 --efi-directory=/boot/efi/ --boot-directory=/boot
sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo update-grub
To check install is correct, issue:
$ [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD]
Two important config files to get a successful Arch Linux or Ubuntu boot are:
grub.cfg
fstab
fstab is in /etc/
/etc/fstab
grub.cfg can be found in /boot/grub & mounted efi partition /boot/efi in /boot/efi/EFI/ubuntu
grub.cfg can be used in a grub command line as follows:
set root=(hd0,gpt2)
configfile (hd0,gpt1)/efi/ubuntu/grub.cfg
(grub.cfg must have the UUID of (hd0,gpt2) in my case of /dev/sdb2
use
sudo blkid /dev/sdX to find UUID's)
or
configfile (hd0,gpt2)/boot/grub/grub.cfg
grub.cfg, fstab examples...
First
Disk /dev/sdb: 931.5 GiB, 1000204885504 bytes, 1953525167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 807AFD80-12D5-03A5-60BF-1E60B544E900
Device Start End Sectors Size Type
/dev/sdb1 2048 206847 204800 100M BIOS boot
/dev/sdb2 206848 135235583 135028736 64.4G Linux filesystem
/dev/sdb3 135235584 286480383 151244800 72.1G Linux filesystem
/dev/sdb4 286480384 599062527 312582144 149.1G Microsoft basic data
/dev/sdb5 599062528 599984127 921600 450M Windows recovery environment
/dev/sdb6 599984128 1007575039 407590912 194.4G Microsoft basic data
/dev/sdb7 1007575040 1949327359 941752320 449.1G Microsoft basic data
/dev/sdb8 1949329408 1953103871 3774464 1.8G Linux swap
/dev/sdb9 1953105920 1953519615 413696 202M EFI System
$ sudo blkid /dev/sdb9
/dev/sdb9: LABEL="UEFI" UUID="B07A-6430" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="f7ffc8f0-896a-01d2-78e0-eb63b544e900"
$ sudo blkid /dev/sdb3
/dev/sdb3: LABEL="UBUNTU16" UUID="8082d3f4-ec43-4310-af55-934b67078f05" TYPE="ext4" PARTLABEL="Basic data partition" PARTUUID="c0428fd0-896a-01d2-e843-2160b544e900"
$ sudo blkid /dev/sdb8
/dev/sdb8: TYPE="swap" PARTLABEL="Basic data partition" PARTUUID="0000e5a5-f7e0-c5fd-6ae9-f2754acb0100"
$ nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdc3 during installation
UUID=6e69ee53-1a57-4cb5-b46f-f0f079fdf666 / ext4
# /boot/efi was on /dev/sda2 during installation
UUID=B07A-6430 /boot/efi vfat defaults 0 1
# swap was on /dev/sdc1 during installation
UUID=0000e5a5-f7e0-c5fd-6ae9-f2754acb0100 none swap sw $
$ nano /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid 3fcb8592-bcc3-cf01-3048-8592bcc3cf01 root hd1,gpt3
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Second
Disk /dev/sda: 465.8 GiB, 500107861504 bytes, 976773167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 4CACF8A0-B3A8-039F-283E-2B13EAECE700
Device Start End Sectors Size Type
/dev/sda1 2048 411647 409600 200M EFI System
/dev/sda2 411648 210208767 209797120 100G Microsoft basic data
/dev/sda3 210415616 337403903 126988288 60.6G Linux filesystem
/dev/sda4 337403904 430872575 93468672 44.6G Linux filesystem
/dev/sda5 430872576 435066879 4194304 2G Linux swap
/dev/sda6 435066880 624490495 189423616 90.3G Microsoft basic data
/dev/sda7 624490496 976766975 352276480 168G Microsoft basic data
/dev/sda8 210208768 210415615 206848 101M BIOS boot
Partition table entries are not in disk order.
$ sudo blkid /dev/sda1
/dev/sda1: LABEL="EFI" UUID="4579-67B0" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="42f7ecf0-d3b5-01d0-78f6-7ba1da69e800"
$ sudo blkid /dev/sda3
/dev/sda3: LABEL="UBUNTU18" UUID="6e69ee53-1a57-4cb5-b46f-f0f079fdf666" TYPE="ext4" PARTUUID="99b3c3d8-2c44-488b-a130-fefb68abbe5d"
$ sudo blkid /dev/sda5
/dev/sda5: UUID="93471658-7099-45fc-ac61-75e09b4bf08f" TYPE="swap" PARTUUID="fdb07319-debf-4394-9e71-27b3bca2a9ac"
$ nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdc3 during installation
UUID=6e69ee53-1a57-4cb5-b46f-f0f079fdf666 / ext4
# /boot/efi was on /dev/sda2 during installation
UUID=4579-67B0 /boot/efi vfat defaults 0 1
# swap was on /dev/sdc1 during installation
UUID=93471658-7099-45fc-ac61-75e09b4bf08f none swap sw
$ nano /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid 6e69ee53-1a57-4cb5-b46f-f0f079fdf666 root hd1,gpt3
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Looking at the above examples, you can tease out where identifiers need be, usually the commands listed on previous posts would look after that, but sometimes they do not, so you need to amend / correct grub.cfg & fstab manually...
I hope this helps
Fixing Windows 10 EFI boot
In multi boot situations installing Ubuntu, one sometimes loses UEFI settings booting Windows 10 - here are some ways to repair / recover...
Resource needed - relevant boot install usb/dvd for Windows 10.
Use diskpart to repair uefi from troubleshooting repair command prompt.

Categories

Resources