{"id":729,"date":"2016-08-05T11:13:03","date_gmt":"2016-08-05T10:13:03","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=729"},"modified":"2016-08-05T12:21:52","modified_gmt":"2016-08-05T11:21:52","slug":"te","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2016\/08\/05\/te\/","title":{"rendered":"Resizing a SD or USB card partition for Retropie Raspberry Pi Arcade on Linux"},"content":{"rendered":"<p>So, I had a friend who had recently bought his Raspberry Pi 3 and wanted to run retropie on it like I have been with my arcade cabinet.<\/p>\n<p><a href=\"http:\/\/www.haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-730\" src=\"http:\/\/www.haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o.jpg\" alt=\"13682010_1735545403352472_192137128_o\" width=\"2048\" height=\"1152\" srcset=\"https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o.jpg 2048w, https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o-300x169.jpg 300w, https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o-768x432.jpg 768w, https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o-1024x576.jpg 1024w, https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13682010_1735545403352472_192137128_o-500x281.jpg 500w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/p>\n<p>The problem was the sandisk 64GB disk he had bought had some few less sectors on the disk, which meant my image was just a few bytes too big. What a bummer!<\/p>\n<p><a href=\"http:\/\/www.haxed.me.uk\/wp-content\/uploads\/2016\/08\/13599828_10153775400798481_3462834024739541253_n.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-731 size-full\" src=\"http:\/\/www.haxed.me.uk\/wp-content\/uploads\/2016\/08\/13599828_10153775400798481_3462834024739541253_n-e1470391911646.jpg\" alt=\"13599828_10153775400798481_3462834024739541253_n\" width=\"712\" height=\"386\" srcset=\"https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13599828_10153775400798481_3462834024739541253_n-e1470391911646.jpg 712w, https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13599828_10153775400798481_3462834024739541253_n-e1470391911646-300x163.jpg 300w, https:\/\/haxed.me.uk\/wp-content\/uploads\/2016\/08\/13599828_10153775400798481_3462834024739541253_n-e1470391911646-500x271.jpg 500w\" sizes=\"auto, (max-width: 712px) 100vw, 712px\" \/><\/a><\/p>\n<p>So I used this great tool by sirlagz to fix that.<\/p>\n<pre>\r\n#!\/bin\/bash\r\n# Automatic Image file resizer\r\n# Written by SirLagz\r\nstrImgFile=$1\r\n\r\n\r\nif [[ ! $(whoami) =~ \"root\" ]]; then\r\necho \"\"\r\necho \"**********************************\"\r\necho \"*** This should be run as root ***\"\r\necho \"**********************************\"\r\necho \"\"\r\nexit\r\nfi\r\n\r\nif [[ -z $1 ]]; then\r\necho \"Usage: .\/autosizer.sh <img \/>\"\r\nexit\r\nfi\r\n\r\nif [[ ! -e $1 || ! $(file $1) =~ \"x86\" ]]; then\r\necho \"Error : Not an image file, or file doesn't exist\"\r\nexit\r\nfi\r\n\r\npartinfo=`parted -m $1 unit B print`\r\npartnumber=`echo \"$partinfo\" | grep ext4 | awk -F: ' { print $1 } '`\r\npartstart=`echo \"$partinfo\" | grep ext4 | awk -F: ' { print substr($2,0,length($2)-1) } '`\r\nloopback=`losetup -f --show -o $partstart $1`\r\ne2fsck -f $loopback\r\nminsize=`resize2fs -P $loopback | awk -F': ' ' { print $2 } '`\r\nminsize=`echo $minsize+1000 | bc`\r\nresize2fs -p $loopback $minsize\r\nsleep 1\r\nlosetup -d $loopback\r\npartnewsize=`echo \"$minsize * 4096\" | bc`\r\nnewpartend=`echo \"$partstart + $partnewsize\" | bc`\r\npart1=`parted $1 rm 2`\r\npart2=`parted $1 unit B mkpart primary $partstart $newpartend`\r\nendresult=`parted -m $1 unit B print free | tail -1 | awk -F: ' { print substr($2,0,length($2)-1) } '`\r\ntruncate -s $endresult $1\r\n\r\n<\/pre>\n<p>It was a nice solution to my friends problem&#8230; the only problem now is the working image for my pi is not working with audio for him, and for some reason when he comes out of hte game and goes back to emulation station he loses the joystick input controller. That is kind of bizarre.<\/p>\n<p>Does anyone know what could cause those secondary issues? I&#8217;m a bit stumped on this one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I had a friend who had recently bought his Raspberry Pi 3 and wanted to run retropie on it like I have been with my arcade cabinet. The problem was the sandisk 64GB disk he had bought had some &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2016\/08\/05\/te\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63,9,7,62,52],"tags":[],"class_list":["post-729","post","type-post","status-publish","format-standard","hentry","category-disk-tools","category-linux","category-management-tools","category-retropie","category-virtualization"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=729"}],"version-history":[{"count":6,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/729\/revisions"}],"predecessor-version":[{"id":738,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/729\/revisions\/738"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}